From bd80c11adc78cbaeaf7f26778bb29be1a6ab0677 Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Sun, 19 Feb 2017 22:17:25 +0100 Subject: [PATCH] Removed Boost Library --- DRAMSys/analyzer/traceAnalyzer.pro | 77 ++++++++++++------- DRAMSys/simulator/library.pro | 17 +--- DRAMSys/simulator/simulator.pro | 4 + DRAMSys/simulator/src/common/TlmRecorder.cpp | 13 +++- DRAMSys/simulator/src/common/Utils.h | 41 ---------- .../core/configuration/Configuration.cpp | 37 ++++++--- .../core/configuration/Configuration.h | 3 +- DRAMSys/simulator/src/simulation/Dram.h | 2 - DRAMSys/simulator/src/simulation/main.cpp | 1 - 9 files changed, 89 insertions(+), 106 deletions(-) diff --git a/DRAMSys/analyzer/traceAnalyzer.pro b/DRAMSys/analyzer/traceAnalyzer.pro index f630aab0..b07b3ec1 100644 --- a/DRAMSys/analyzer/traceAnalyzer.pro +++ b/DRAMSys/analyzer/traceAnalyzer.pro @@ -11,26 +11,27 @@ CONFIG += no_keywords CONFIG += python + unix:!macx { - QMAKE_CXXFLAGS += -std=c++11 - CONFIG += qwt - QMAKE_CXXFLAGS += -Xlinker -export-dynamic - QMAKE_RPATHDIR += $${libqwt_home} - message(Linker options QMAKE_RPATHDIR is $${QMAKE_RPATHDIR}) + # Python library and header files + python_home = $$(PYTHON_HOME) + isEmpty(python_home) { + python_home = /opt/python/lib + } + message(Python home is $${python_home}) + + python_headers = $$(PYTHON_HEADERS) + isEmpty(python_headers) { + python_headers = /opt/python/include/python3.5m + } + message(Getting python headers from $${python_headers}) + + QMAKE_CXXFLAGS += -std=c++11 + CONFIG += qwt + QMAKE_CXXFLAGS += -Xlinker -export-dynamic + QMAKE_RPATHDIR += $${libqwt_home} + message(Linker options QMAKE_RPATHDIR is $${QMAKE_RPATHDIR}) - # Python library and header files - python_home = $$(PYTHON_HOME) - isEmpty(python_home) { - python_home = /opt/python/lib - } - message(Python home is $${python_home}) - - python_headers = $$(PYTHON_HEADERS) - isEmpty(python_headers) { - python_headers = /opt/python/include/python3.5m - } - message(Getting python headers from $${python_headers}) - CONFIG(python){ LIBS += -L$${python_home} -lpython3.5m INCLUDEPATH += $${python_headers} @@ -38,15 +39,36 @@ unix:!macx { } macx: { - CONFIG += c++11 - QMAKE_CXXFLAGS += -std=c++0x -stdlib=libc++ - QMAKE_LFLAGS += -F$$(LIBQWT_HOME) - LIBS += -F$$(LIBQWT_HOME) -framework qwt - INCLUDEPATH += $$(LIBQWT_HEADERS) - DEPENDPATH += $$replace(LIBQWT_HOME, lib, ) - INCLUDEPATH += $$(PYTHON_HEADERS) - LIBS += -L$$(PYTHON_HOME) -lpython3.6 - CONFIG-=app_bundle + message(Building on a MAC) + # Python library and header files + python_home = $$(PYTHON_HOME) + isEmpty(python_home) { + python_home = /usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/ + } + message(Python home is $${python_home}) + + python_headers = $$(PYTHON_HEADERS) + isEmpty(python_headers) { + python_headers = /usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/Headers/ + } + message(Getting python headers from $${python_headers}) + + CONFIG += c++11 + QMAKE_CXXFLAGS += -std=c++0x -stdlib=libc++ + + QMAKE_LFLAGS += -F$$(LIBQWT_HOME) + LIBS += -F$$(LIBQWT_HOME) -framework qwt + INCLUDEPATH += $$(LIBQWT_HEADERS) + DEPENDPATH += $$replace(LIBQWT_HOME, lib, ) + + #DEPENDPATH += $$(python_headers) + #INCLUDEPATH += $$(python_headers) + #LIBS += -L$$(python_home) -lpython3.6 + + INCLUDEPATH += /usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/Headers/ + LIBS += -L/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/ -lpython3.6 + + CONFIG-=app_bundle } # QWT library and header files @@ -158,6 +180,5 @@ FORMS += \ evaluationtool.ui # Additional Files: -# scripts (DRAMSys/analyzer/scripts) include(scripts/scripts.pri) diff --git a/DRAMSys/simulator/library.pro b/DRAMSys/simulator/library.pro index 6a0bc61e..d026282c 100644 --- a/DRAMSys/simulator/library.pro +++ b/DRAMSys/simulator/library.pro @@ -1,6 +1,7 @@ TARGET = DRAMSys TEMPLATE = lib +CONFIG += staticlib CONFIG += console CONFIG -= app_bundle CONFIG -= qt @@ -22,28 +23,13 @@ message(SystemC target architecture is $${systemc_target_arch}) QMAKE_RPATHDIR += $${systemc_home}/lib-$${systemc_target_arch} message(Linker options QMAKE_RPATHDIR is $${QMAKE_RPATHDIR}) -libboost_home = $$(LIBBOOST_HOME) -isEmpty(libboost_home) { - libboost_home = /opt/boost/lib -} -message(LIBBOOST home is $${libboost_home}) - LIBS += -L$${systemc_home}/lib-$${systemc_target_arch} -lsystemc -LIBS += -L$${libboost_home} -lboost_filesystem -lboost_system - LIBS += -lsqlite3 LIBS += -lpthread LIBS += -L../../DRAMSys/simulator/src/common/third_party/DRAMPower/src/ -ldrampower -libboost_headers = $$(LIBBOOST_HEADERS) -isEmpty(libboost_headers) { - libboost_headers = /opt/boost/include -} -message(Getting LIBOOST headers from $${libboost_headers}) - INCLUDEPATH += $${systemc_home}/include -INCLUDEPATH += $${libboost_headers} INCLUDEPATH += src/common/third_party/DRAMPower/src INCLUDEPATH += src/common/third_party/DRAMPower/src/libdrampower @@ -60,7 +46,6 @@ macx: { } QMAKE_CXXFLAGS += -isystem $${systemc_home}/include -QMAKE_CXXFLAGS += -isystem $${libboost_headers} SOURCES += \ src/common/third_party/tinyxml2/tinyxml2.cpp \ diff --git a/DRAMSys/simulator/simulator.pro b/DRAMSys/simulator/simulator.pro index 02dfd04e..e7d0dd4d 100644 --- a/DRAMSys/simulator/simulator.pro +++ b/DRAMSys/simulator/simulator.pro @@ -19,8 +19,12 @@ message(SystemC target architecture is $${systemc_target_arch}) INCLUDEPATH += src/simulation/ INCLUDEPATH += $${systemc_home}/include +INCLUDEPATH += src/common/third_party/DRAMPower/src +INCLUDEPATH += src/common/third_party/DRAMPower/src/libdrampower +LIBS += -lsqlite3 LIBS += -L$${systemc_home}/lib-$${systemc_target_arch} -lsystemc +LIBS += -L../../DRAMSys/simulator/src/common/third_party/DRAMPower/src/ -ldrampower LIBS += -L$${OUT_PWD} -ldramSys SOURCES += src/simulation/main.cpp diff --git a/DRAMSys/simulator/src/common/TlmRecorder.cpp b/DRAMSys/simulator/src/common/TlmRecorder.cpp index 0f2466f4..8fbe5a69 100644 --- a/DRAMSys/simulator/src/common/TlmRecorder.cpp +++ b/DRAMSys/simulator/src/common/TlmRecorder.cpp @@ -38,7 +38,6 @@ #include #include -#include #include "TlmRecorder.h" #include "protocol.h" @@ -219,9 +218,15 @@ void TlmRecorder::Transaction::setPhaseEnd(string name, sc_time end) void TlmRecorder::openDB(std::string name) { - boost::filesystem::wpath file(name); - if(boost::filesystem::exists(file)) - boost::filesystem::remove(file); + ifstream f(name.c_str()); + if(f.good()) + { + if(remove(name.c_str()) != 0) + { + SC_REPORT_FATAL("TlmRecorder", "Error deleting file" ); + } + } + if (sqlite3_open(name.c_str(), &db) != SQLITE_OK) { SC_REPORT_FATAL("Error in TraceRecorder", "Error cannot open database"); diff --git a/DRAMSys/simulator/src/common/Utils.h b/DRAMSys/simulator/src/common/Utils.h index c8c8d85e..98212eda 100644 --- a/DRAMSys/simulator/src/common/Utils.h +++ b/DRAMSys/simulator/src/common/Utils.h @@ -43,7 +43,6 @@ #include #include #include -#include #include #include "dramExtension.h" #include "third_party/tinyxml2/tinyxml2.h" @@ -127,45 +126,5 @@ double queryDoubleParameter(tinyxml2::XMLElement* node, std::string name); void setUpDummy(tlm::tlm_generic_payload& payload, Bank& bank); -#define DEFINE_ENUM_CLASS_WITH_STRING_CONVERSIONS_TOSTRING_CASE(r, data, elem) \ - case data::elem : return BOOST_PP_STRINGIZE(elem); - -#define DEFINE_ENUM_CLASS_WITH_STRING_CONVERSIONS_TOENUM_IF(r, data, elem) \ - if (BOOST_PP_SEQ_TAIL(data) == BOOST_PP_STRINGIZE(elem)) \ - return BOOST_PP_SEQ_HEAD(data)::elem; else - -#define DEFINE_ENUM_CLASS_WITH_STRING_CONVERSIONS(enumName, enumerators) \ - enum class enumName { \ - BOOST_PP_SEQ_ENUM(enumerators) \ - }; \ - \ - inline const char *EnumToString(enumName v) \ - { \ - switch (v) { \ - BOOST_PP_SEQ_FOR_EACH( \ - DEFINE_ENUM_CLASS_WITH_STRING_CONVERSIONS_TOSTRING_CASE, \ - enumName, \ - enumerators \ - ) \ - default: return "[Unknown " BOOST_PP_STRINGIZE(name) "]"; \ - } \ - } \ - \ - inline enumName StringToEnum(std::string s) \ - { \ - BOOST_PP_SEQ_FOR_EACH( \ - DEFINE_ENUM_CLASS_WITH_STRING_CONVERSIONS_TOENUM_IF, \ - (enumName)(s), \ - enumerators \ - ) \ - { \ - SC_REPORT_FATAL("Configuration", \ - ("Invalid string \"" + s + "\" for conversion into enum \"" \ - + BOOST_PP_STRINGIZE(enumName) + "\"").c_str() \ - ); \ - \ - } \ - } - #endif /* UTILS_COMMON_H_ */ diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index 03532fa4..d0f18424 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -40,7 +40,6 @@ #include "Configuration.h" #include "ConfigurationLoader.h" -#include "boost/lexical_cast.hpp" #include "../../../common/xmlAddressdecoder.h" using namespace std; @@ -54,22 +53,36 @@ Configuration::Configuration() int string2bool(string s) { - try { - bool x = boost::lexical_cast( s ); - return x; - } catch( boost::bad_lexical_cast const& ) { + if(s=="0") + { + return 0; + } + else if(s=="1") + { + return 1; + } + else + { SC_REPORT_FATAL("Configuration", ("Could not convert to bool: " + s).c_str()); - throw; } } int string2int(string s) { - try { - int x = boost::lexical_cast( s ); - return x; - } catch( boost::bad_lexical_cast const& ) { - SC_REPORT_FATAL("Configuration", ("Could not convert to int: " + s).c_str()); + return std::stoi(s); +} + +StorageMode string2StoreMode(string s) +{ + if(s == "NoStorage") + return StorageMode::NoStorage; + else if(s == "Store") + return StorageMode::Store; + else if (s == "ErrorModel") + return StorageMode::ErrorModel; + else + { + SC_REPORT_FATAL("Configuration", ("Unknown StorageMode: " + s).c_str()); throw; } } @@ -179,7 +192,7 @@ void Configuration::setParameter(std::string name, std::string value) else if(name == "ErrorCSVFile") ErrorCSVFile = value; else if(name == "StoreMode") - StoreMode = StringToEnum(value); + StoreMode = string2StoreMode(value); // Temperature Simulation related else if (name == "TemperatureScale") { if (value != "Celsius" && value != "Fahrenheit" && value != "Kelvin") { diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h index 3a0c1b37..21977e78 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h @@ -45,8 +45,7 @@ #include "thermalSimConfig.h" #include "../../../common/Utils.h" -enum class StorageMode; -DEFINE_ENUM_CLASS_WITH_STRING_CONVERSIONS(StorageMode, (NoStorage)(Store)(ErrorModel)) +enum class StorageMode{NoStorage, Store, ErrorModel}; enum class EPowerDownMode{NoPowerDown, Staggered, TimeoutPDN, TimeoutSREF}; diff --git a/DRAMSys/simulator/src/simulation/Dram.h b/DRAMSys/simulator/src/simulation/Dram.h index 430e96ae..c86255ce 100644 --- a/DRAMSys/simulator/src/simulation/Dram.h +++ b/DRAMSys/simulator/src/simulation/Dram.h @@ -194,8 +194,6 @@ struct Dram : sc_module firstAccess = SC_ZERO_TIME; lastAccess = SC_ZERO_TIME; - printDebugMessage(string("StorageMode: ") + EnumToString(StoreMode)); - // For each bank in a channel a error Model is created: if(StoreMode == StorageMode::ErrorModel) { diff --git a/DRAMSys/simulator/src/simulation/main.cpp b/DRAMSys/simulator/src/simulation/main.cpp index e6a4388d..18e00f77 100644 --- a/DRAMSys/simulator/src/simulation/main.cpp +++ b/DRAMSys/simulator/src/simulation/main.cpp @@ -42,7 +42,6 @@ #include "DRAMSys.h" #include "TraceSetup.h" -#include "ExampleInitiator.h" using namespace std;