OpenASIP 2.2
Loading...
Searching...
No Matches
DSDBManager.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2011 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.cc
26 *
27 * Implementation of DSDBManager class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30 * @author Pekka Jääskeläinen 2011
31 * @note rating: red
32 */
33
34#include <boost/format.hpp>
35#include <boost/tuple/tuple_comparison.hpp>
36#include <utility>
37#include "DSDBManager.hh"
38#include "SQLite.hh"
41#include "ADFSerializer.hh"
42#include "IDFSerializer.hh"
43#include "Conversion.hh"
44#include "Machine.hh"
46#include "DataObject.hh"
47#include "FileSystem.hh"
49#include "ObjectState.hh"
50
51using std::pair;
52using std::map;
53using std::set;
54using std::vector;
55using std::make_pair;
56using std::string;
57using namespace CostEstimator;
58
59const string CREATE_ARCH_TABLE =
60 "CREATE TABLE architecture ("
61 " id INTEGER PRIMARY KEY,"
62 " connection_count INTEGER DEFAULT NULL, "
63 " adf_hash VARCHAR,"
64 " adf_xml VARCHAR)";
65
66const string CREATE_IMPL_TABLE =
67 "CREATE TABLE implementation ("
68 " id INTEGER PRIMARY KEY,"
69 " idf_xml VARCHAR,"
70 " lpd DOUBLE,"
71 " area INTEGER)";
72
74 "CREATE TABLE machine_configuration ("
75 " id INTEGER PRIMARY KEY,"
76 " architecture REFERENCES architecture(id) NOT NULL,"
77 " implementation REFERENCES implementation(id))";
78
80 "CREATE TABLE application ("
81 " id INTEGER PRIMARY KEY,"
82 " path varchar)";
83
85 "CREATE TABLE cycle_count ("
86 " architecture REFERENCES architecture(id) NOT NULL,"
87 " application REFERENCES application(id) NOT NULL,"
88// this is set to TRUE in case cycle count production failed due to
89// unschedulable program
90 " unschedulable BOOL DEFAULT 0,"
91 " cycles BIGINT DEFAULT NULL)";
92
94 "CREATE TABLE energy_estimate ("
95 " implementation REFERENCES implementation(id) NOT NULL,"
96 " application REFERENCES application(id) NOT NULL,"
97 " energy_estimate DOUBLE NOT NULL)";
98
99
100/**
101 * The Constructor.
102 *
103 * Loads a DSDB from the given file.
104 *
105 * @param file DSDB file to load.
106 * @throw IOException if the DSDB file couldn't be succesfully loaded.
107 */
108DSDBManager::DSDBManager(const std::string& file)
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}
122
123/**
124 * The Destructor.
125 *
126 * Closes the database connection.
127 */
132
133/**
134 * Creates a new DSDB file, and a DSDB manager for it.
135 *
136 * @param file Full path to the DSDB file to create.
137 * @return An instance of DSDBManager with the newly created empty DSDB.
138 * @throw IOException if the DSDB file creation was not succesful.
139 */
141DSDBManager::createNew(const std::string& file) {
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}
170
171/**
172 * Returns absolute path of the database file.
173 *
174 * @return Database file path.
175 */
176std::string
180
181/**
182 * Adds machine architecture to the database.
183 *
184 * In case an existing equal architecture is found in the DB,
185 * does not add a new one, but returns the ID of the old one.
186 *
187 * @param mom Machine architecture to add.
188 * @return RowID of the added architecture.
189 */
190RowID
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}
242
243/**
244 * Adds machine implementation to the database.
245 *
246 * @param impl Machine implementation to add.
247 * @param longestPathDelay Longest path delay in seconds.
248 * @param area Area as number of gates.
249 * @return RowID of the added architecture.
250 */
251RowID
253 const IDF::MachineImplementation& impl, double longestPathDelay,
254 AreaInGates area) {
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}
288
289/**
290 * Adds a new machine configuration to the database.
291 *
292 * In case a same configuration found in the DB, reuses that one.
293 *
294 * @param conf Configuration to add.
295 * @return RowID of the new configuration.
296 * @throw KeyNotFound if the configuration contained unknown IDs.
297 */
298RowID
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 " +
309 "not found.";
310 throw KeyNotFound(__FILE__, __LINE__, __func__, msg);
311 }
312
314 std::string msg =
315 "Implementation with ID " +
317 " not found.";
318 throw KeyNotFound(__FILE__, __LINE__, __func__, msg);
319 }
320
321 try {
323 std::string implID;
324 if (conf.hasImplementation) {
326 } else {
327 implID = "NULL";
328 }
329
331 std::string(
332 "INSERT INTO machine_configuration("
333 "id, architecture, implementation) VALUES"
334 "(NULL,") +
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}
352
353/**
354 * Returns machine configuration with the give ID.
355 *
356 * @param id ID of the machine configuration to return.
357 * @return Machine configuration with the give ID.
358 * @throw KeyNotFound If a configuration with the given ID was not found.
359 */
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();
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}
398
399/**
400 * Removes configuration with the give ID from the database.
401 *
402 * Arhcitecture and implementation that are referenced by the configuration
403 * are not removed.
404 *
405 * @param id ID of the configuration to remove.
406 * @throw KeyNotFound If a configuration ID was not found in the database.
407 */
408void
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}
431
432/**
433 * Adds a new application to the database.
434 *
435 * @param path Path of the application test case.
436 * @return RowID of the added application.
437 * @exception InvalidData in case the application dir is not valid.
438 */
439RowID
440DSDBManager::addApplication(const std::string& path) {
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}
468
469/**
470 * Adds an energy estimate for application on specific implementation.
471 *
472 * @param application RowID of the application.
473 * @param implementation RowID of the machine implementation.
474 * @param energy Application energy estimate as joules.
475 */
476void
478 RowID application, RowID implementation, double energyEstimate) {
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}
503
504/**
505 * Sets the application to be unschedulable for an architecture,
506 * thus cycle count nor further estimation could not be done.
507 *
508 * This is saved to the DB so future evaluations of the same architecture
509 * can be skipped.
510 *
511 * @param application RowID of the application.
512 * @param architecture RowID of the machine architecture.
513 */
514void
515DSDBManager::setUnschedulable(RowID application, RowID architecture) {
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}
539
540/**
541 * Checks if the application has been scheduled for the given
542 * architecture previously unsuccessfully.
543 *
544 * @param application RowID of the application.
545 * @param architecture RowID of the machine architecture.
546 * @return True, if it's known that the application is unschedulable
547 * for the given architecture.
548 */
549bool
551 RowID application, RowID architecture) const {
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}
573
574
575/**
576 * Adds cycle count of an application on specific architecture.
577 *
578 * @param application RowID of the application.
579 * @param architecture RowID of the machine architecture.
580 * @param count Cycle count
581 */
582void
584 RowID application, RowID architecture, ClockCycleCount count) {
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}
609
610/**
611 * Sets the longest path delay estimate for an implementation.
612 *
613 * @param implementation RowID of the machine implementation.
614 * @param delay Longest path delay estimate of implementation in nanoseconds.
615 */
616void
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}
633
634/**
635 * Sets the area estimate for an implementation.
636 *
637 * @param implementation RowID of the machine implementation.
638 * @param area Implementation area estimate in gates.
639 */
640void
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}
657
658/**
659 * Returns the machine architecture of the given id as string.
660 *
661 * @param id RowID of the machine architecture.
662 * @return The architecture as string.
663 */
664std::string
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}
695
696/**
697 * Returns the row ID of the given architecture.
698 *
699 * Searches for the architecture using its Machine::hash() string.
700 *e
701 * @param id RowID of the machine architecture. ILLEGAL_ROW_ID, if not found.
702 * @return The architecture ID.
703 */
704RowID
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}
729
730/**
731 * Returns the cycle counts for the given configuration for all applications,
732 * if known.
733 *
734 * @return The cycle counts ordered by the application order.
735 * Empty if at least one application missed a cycle count.
736 */
737std::vector<ClockCycleCount>
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}
753
754
755/**
756 * Returns the row ID of the given configuration.
757 *
758 * @param id RowID of the configuration. ILLEGAL_ROW_ID, if not found.
759 * @return The configuration ID.
760 */
761RowID
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}
798
799
800/**
801 * Returns machine architecture with the given id.
802 *
803 * @param id RowID of the machine architecture.
804 * @return Machine object model of the architecture.
805 */
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}
818
819/**
820 * Writes the machine architecture of given ID to file.
821 *
822 * @param id RowID of the machine architecture.
823 * @param path File path where the ADF file is written.
824 */
825void
826DSDBManager::writeArchitectureToFile(RowID id, const std::string& path) const {
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}
839
840/**
841 * Returns machine implementation with the given id as string.
842 *
843 * @param id RowID of the machine implementation.
844 * @return The implementation as string.
845 */
846std::string
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}
879
880/**
881 * Returns machine implementation with the given id.
882 *
883 * @param id RowID of the machine implementation.
884 * @return MachineImplementation object containing the implementation.
885 */
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}
898
899/**
900 * Writes the machine implementation of given ID to file.
901 *
902 * @param id RowID of the machine implementation.
903 * @param path File path where the IDF file is written.
904 */
905void
907 RowID id, const std::string& path) const {
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}
920
921/**
922 * Writes the machine configuration to files path.{idf,adf}.
923 *
924 * @param conf MachineConfiguration to be written to a path.
925 * @param path Path where the ADF and possibly the IDF of the configuration
926 * will be written.
927 */
928void
930 const MachineConfiguration& conf, const std::string& path) {
931 const std::string adfFile = path + ".adf";
932 const std::string idfFile = path + ".idf";
933
935 if (conf.hasImplementation) {
937 }
938}
939
940/**
941 * Returns path of an application with the given ID.
942 *
943 * @param id RowID of the application test case.
944 * @return Path of the application test case.
945 */
946std::string
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}
973
974/**
975 * Checks if energy estimate exists for an application and implementation
976 * with given IDs.
977 *
978 * @param application ID of the application.
979 * @param implementation ID of the machine implementation.
980 * @return True, if an energy estimate exists in the DB.
981 */
982bool
984 const {
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}
1005
1006/**
1007 * Checks if the database contains application with the given RowID.
1008 *
1009 * @param id ID of the application.
1010 * @return True, if an application with the given ID exists in the DB.
1011 */
1012bool
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}
1033
1034/**
1035 * Checks if the database contains application with the given application path.
1036 *
1037 * @param applicationPath Path of the application.
1038 * @return True, if an application with the given path exists in the DB.
1039 */
1040bool
1041DSDBManager::hasApplication(const std::string& applicationPath) const {
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}
1064
1065/**
1066 * Removes the application that has the given ID.
1067 * @param id Application ID to remove.
1068 * @exception KeyNotFound If the application ID was not found in the database.
1069 */
1070void
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}
1093
1094/**
1095 * Checks if the database contains architecture with the given RowID.
1096 *
1097 * @param id ID of the architecture.
1098 * @return True, if an architecture with the given ID exists in the DB.
1099 */
1100bool
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}
1121
1122/**
1123 * Checks if the database contains configuration with the given RowID.
1124 *
1125 * @param id ID of the configuration.
1126 * @return True, if a configuration with the given ID exists in the DB.
1127 */
1128bool
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}
1149
1150/**
1151 * Checks if the database contains implementation with the given RowID.
1152 *
1153 * @param id ID of the implementation
1154 * @return True, if implementation with the given ID exists in the DB.
1155 */
1156bool
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}
1177
1178/**
1179 * Returns energy estimate for an application on specific implementation.
1180 *
1181 * @param application RowID of the application.
1182 * @param implementation RowID of the implementation.
1183 * @return Energy estimate in joules.
1184 * @exception KeyNotFound If an energy estimate was not found.
1185 */
1186double
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}
1218
1219/**
1220 * Checks if cycle count exists for an application and architecture
1221 * with given IDs.
1222 *
1223 * @param application ID of the application.
1224 * @param architecture ID of the machine architecture
1225 * @return True, if a cycle count exists in the DB.
1226 */
1227bool
1228DSDBManager::hasCycleCount(RowID application, RowID architecture) const {
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}
1250
1251
1252/**
1253 * Returns cycle count for an application on specific architecture.
1254 *
1255 * @param application RowID of the application.
1256 * @param architecture RowID of the architecture.
1257 * @return Cycle count in cycles.
1258 * @exception KeyNotFound If cycle count was not found in DB.
1259 */
1261DSDBManager::cycleCount(RowID application, RowID architecture) const {
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}
1294
1295/**
1296 * Returns longest path delay estimate for an specific implementation.
1297 *
1298 * @param implementation RowID of the machine implementation.
1299 * @return Longest path delay in nanoseconds.
1300 * @exception KeyNotFound If the implmentation was not found in DB.
1301 */
1302double
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}
1334
1335/**
1336 * Returns area estimate for an specific implementation.
1337 *
1338 * @param implementation RowID of the machine implementation.
1339 * @return Area estimate in gates.
1340 * @exception KeyNotFound If the implementation was not found in DB.
1341 */
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}
1374
1375/**
1376 * Returns IDs of all applications in the database.
1377 *
1378 * @return RowIDs of all applications in the database.
1379 */
1380std::set<RowID>
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}
1409
1410/**
1411 * Returns IDs of all machine architectures in the database.
1412 *
1413 * @return RowIDs of all architectures in the database.
1414 */
1415std::set<RowID>
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}
1444
1445/**
1446 * Returns IDs of all machine configurations in the database.
1447 *
1448 * @return RowIDs of all configurations in the database.
1449 */
1450std::set<RowID>
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}
1479
1480/**
1481 * Returns IDs of all configurations referencing the given architecture.
1482 *
1483 * @param architectureID ID of the architecture to search configurations for.
1484 * @return Configuration IDs of a machine architecture.
1485 */
1486std::set<RowID>
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}
1515
1516/**
1517 * Returs set of ConfigurationCosts ordered by the given ordering.
1518 *
1519 * @param ordering Ordering of the results.
1520 * @return ConfigurationCosts of all configurations in the DSDB ordered by
1521 * the given option.
1522 */
1523std::vector<DSDBManager::ConfigurationCosts>
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++) {
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}
1659
1660/**
1661 * Returns the number of applications in the dsdb.
1662 *
1663 * @return The number of applications in the dsdb.
1664 */
1665int
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}
1691
1692/**
1693 * Finds a pareto set of configurations using the connection count and the
1694 * cycle count of the given application as criteria.
1695 */
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}
#define debugLog(text)
#define __func__
#define abortWithError(message)
#define assert(condition)
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
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
#define ILLEGAL_ROW_ID
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
CycleCount ClockCycleCount
Alias for ClockCycleCount.
void writeState(const ObjectState *machineState)
ObjectState * readState()
static std::string toString(const T &source)
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
IDF::MachineImplementation * implementation(RowID id) 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
DSDBManager(const std::string &file)
void addEnergyEstimate(RowID application, RowID implementation, double energyEstimate)
virtual std::string stringValue() const
virtual bool isNull() const
virtual double doubleValue() const
virtual int integerValue() const
std::string errorMessage() const
Definition Exception.cc:123
static std::string absolutePathOf(const std::string &pathName)
static const std::string DIRECTORY_SEPARATOR
static bool fileIsCreatable(const std::string fileName)
static bool fileExists(const std::string fileName)
virtual void writeState(const ObjectState *state)
virtual ObjectState * readState()
virtual void loadState(const ObjectState *state)
virtual ObjectState * saveState() const
static int totalConnectionCount(const TTAMachine::Machine &mach)
virtual int updateQuery(const std::string &queryString)=0
virtual RowID lastInsertRowID()=0
virtual RelationalDBQueryResult * query(const std::string &queryString, bool init=true)=0
virtual void DDLQuery(const std::string &queryString)=0
virtual const DataObject & data(std::size_t column) const =0
virtual void close(const RelationalDBConnection &connection)
Definition SQLite.cc:100
virtual RelationalDBConnection & connect(const std::string &database, const std::string &login="", const std::string &password="", bool readOnly=false)
Definition SQLite.cc:69
TCEString hash() const
Definition Machine.cc:926
virtual void loadState(const ObjectState *state)
Definition Machine.cc:728
virtual ObjectState * saveState() const
Definition Machine.cc:686
void setSourceString(const std::string &source)
void setDestinationFile(const std::string &fileName)
void setDestinationString(std::string &destination)
double AreaInGates
type for area values in equivalent gates
Struct for configuration costs with a specified application.