From f8578ef0aa366257c60fb6e9f004e0f476a7ea73 Mon Sep 17 00:00:00 2001 From: "Emilio G. Cota" Date: Mon, 3 Nov 2014 16:58:15 -0500 Subject: [PATCH 1/9] example_app: pass missing bool argument to printStats Otherwise it does not build. Signed-off-by: Emilio G. Cota --- example_app/dramsim_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_app/dramsim_test.cpp b/example_app/dramsim_test.cpp index cf176f5..b1decb7 100644 --- a/example_app/dramsim_test.cpp +++ b/example_app/dramsim_test.cpp @@ -84,7 +84,7 @@ int some_object::add_one_and_run(MultiChannelMemorySystem *mem, uint64_t addr) } /* get a nice summary of this epoch */ - mem->printStats(); + mem->printStats(true); return 0; } From b1c7d92735960f4d2a9ac67a379d232d41102be2 Mon Sep 17 00:00:00 2001 From: "Emilio G. Cota" Date: Mon, 3 Nov 2014 20:14:09 -0500 Subject: [PATCH 2/9] example_app: add dramsim_test to .gitignore Signed-off-by: Emilio G. Cota --- example_app/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 example_app/.gitignore diff --git a/example_app/.gitignore b/example_app/.gitignore new file mode 100644 index 0000000..485be5f --- /dev/null +++ b/example_app/.gitignore @@ -0,0 +1 @@ +dramsim_test From bb391f088ebbf5a9120cab97824a79c5807e51e1 Mon Sep 17 00:00:00 2001 From: "Emilio G. Cota" Date: Mon, 3 Nov 2014 20:13:31 -0500 Subject: [PATCH 3/9] gitignore: add *.deppo Signed-off-by: Emilio G. Cota --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c7d6939..57dcfd6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ results/ *.o *.po *.dep +*.deppo *.swp DRAMSim libdramsim.so From d181a1bb3a6a728e93822dbd0d9d7f3c4d00baa6 Mon Sep 17 00:00:00 2001 From: "Emilio G. Cota" Date: Tue, 4 Nov 2014 16:29:16 -0500 Subject: [PATCH 4/9] traces: add *.trc to gitignore Signed-off-by: Emilio G. Cota --- traces/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 traces/.gitignore diff --git a/traces/.gitignore b/traces/.gitignore new file mode 100644 index 0000000..c1bdf5f --- /dev/null +++ b/traces/.gitignore @@ -0,0 +1 @@ +*.trc From 74ba4181fd5fabc56bbba6a3105c44d6927df214 Mon Sep 17 00:00:00 2001 From: "Emilio G. Cota" Date: Mon, 3 Nov 2014 20:26:50 -0500 Subject: [PATCH 5/9] TraceBasedSim: remove unused variable 'dramsim_logfile' Signed-off-by: Emilio G. Cota --- TraceBasedSim.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TraceBasedSim.cpp b/TraceBasedSim.cpp index a2757df..a1cbfe1 100644 --- a/TraceBasedSim.cpp +++ b/TraceBasedSim.cpp @@ -510,7 +510,7 @@ int main(int argc, char **argv) MultiChannelMemorySystem *memorySystem = new MultiChannelMemorySystem(deviceIniFilename, systemIniFilename, pwdString, traceFileName, megsOfMemory, visFilename, paramOverrides); // set the frequency ratio to 1:1 memorySystem->setCPUClockSpeed(0); - std::ostream &dramsim_logfile = memorySystem->getLogFile(); + // don't need this anymore delete paramOverrides; From ee64e5c9872a79c5ea02bb56b81e00534cb831f9 Mon Sep 17 00:00:00 2001 From: "Emilio G. Cota" Date: Mon, 3 Nov 2014 20:14:53 -0500 Subject: [PATCH 6/9] PrintMacros: add missing include of The header file should be safely included even if there are no other previously included header files. Fix it. Signed-off-by: Emilio G. Cota --- PrintMacros.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PrintMacros.h b/PrintMacros.h index 134fe65..e55d154 100644 --- a/PrintMacros.h +++ b/PrintMacros.h @@ -35,6 +35,8 @@ #ifndef PRINT_MACROS_H #define PRINT_MACROS_H +#include + extern int SHOW_SIM_OUTPUT; //enable or disable PRINT() statements -- set by flag in TraceBasedSim.cpp #define ERROR(str) std::cerr<<"[ERROR ("<<__FILE__<<":"<<__LINE__<<")]: "< Date: Mon, 3 Nov 2014 20:22:15 -0500 Subject: [PATCH 7/9] PrintMacros: define SHOW_SIM_OUTPUT as weak symbol When linking against libdramsim, library users have to define SHOW_SIM_OUTPUT in order to avoid linking errors. Fix it by emitting a weak version of the symbol. In case of the DRAMSim tool, this weak symbol is overridden by the (strong) symbol in the TraceBasedSim object. Library users can optionally override the weak symbol, which means that a) New users of the library just won't have to worry about this, since they won't see an error at link time. They'll still be able to enable output by defining a strong symbol. b) Existing users of the library will probably have already set a strong symbol, which will override the weak symbol we define here, and thus everything will work as before. Signed-off-by: Emilio G. Cota --- PrintMacros.cpp | 11 +++++++++++ PrintMacros.h | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 PrintMacros.cpp diff --git a/PrintMacros.cpp b/PrintMacros.cpp new file mode 100644 index 0000000..f005667 --- /dev/null +++ b/PrintMacros.cpp @@ -0,0 +1,11 @@ +#include "PrintMacros.h" + +/* + * Enable or disable PRINT() statements. + * + * Set by flag in TraceBasedSim.cpp when compiling standalone DRAMSim tool. + * + * The DRAMSim libraries do not include the TraceBasedSim object and thus + * library users can optionally override the weak definition below. + */ +int __attribute__((weak)) SHOW_SIM_OUTPUT = false; diff --git a/PrintMacros.h b/PrintMacros.h index e55d154..80d6718 100644 --- a/PrintMacros.h +++ b/PrintMacros.h @@ -37,7 +37,7 @@ #include -extern int SHOW_SIM_OUTPUT; //enable or disable PRINT() statements -- set by flag in TraceBasedSim.cpp +extern int SHOW_SIM_OUTPUT; #define ERROR(str) std::cerr<<"[ERROR ("<<__FILE__<<":"<<__LINE__<<")]: "< Date: Mon, 3 Nov 2014 17:00:40 -0500 Subject: [PATCH 8/9] Makefile: do not include TraceBasedSim object in library This object should only be part of the DRAMSim executable. Fix it. Signed-off-by: Emilio G. Cota --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index abfd563..1ed297c 100644 --- a/Makefile +++ b/Makefile @@ -16,8 +16,11 @@ LIB_NAME_MACOS=libdramsim.dylib SRC = $(wildcard *.cpp) OBJ = $(addsuffix .o, $(basename $(SRC))) +LIB_SRC := $(filter-out TraceBasedSim.cpp,$(SRC)) +LIB_OBJ := $(addsuffix .o, $(basename $(LIB_SRC))) + #build portable objects (i.e. with -fPIC) -POBJ = $(addsuffix .po, $(basename $(SRC))) +POBJ = $(addsuffix .po, $(basename $(LIB_SRC))) REBUILDABLES=$(OBJ) ${POBJ} $(EXE_NAME) $(LIB_NAME) From a016449524cd64b50e26d6dd56cb4c94d4bd9bfe Mon Sep 17 00:00:00 2001 From: "Emilio G. Cota" Date: Mon, 3 Nov 2014 17:02:12 -0500 Subject: [PATCH 9/9] Makefile: build static library with libdramsim.a Signed-off-by: Emilio G. Cota --- .gitignore | 1 + Makefile | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 57dcfd6..7e9145a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ results/ *.deppo *.swp DRAMSim +libdramsim.a libdramsim.so diff --git a/Makefile b/Makefile index 1ed297c..2e6a4c6 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ endif CXXFLAGS+=$(OPTFLAGS) EXE_NAME=DRAMSim +STATIC_LIB_NAME := libdramsim.a LIB_NAME=libdramsim.so LIB_NAME_MACOS=libdramsim.dylib @@ -22,7 +23,7 @@ LIB_OBJ := $(addsuffix .o, $(basename $(LIB_SRC))) #build portable objects (i.e. with -fPIC) POBJ = $(addsuffix .po, $(basename $(LIB_SRC))) -REBUILDABLES=$(OBJ) ${POBJ} $(EXE_NAME) $(LIB_NAME) +REBUILDABLES=$(OBJ) ${POBJ} $(EXE_NAME) $(LIB_NAME) $(STATIC_LIB_NAME) all: ${EXE_NAME} @@ -35,6 +36,9 @@ $(LIB_NAME): $(POBJ) g++ -g -shared -Wl,-soname,$@ -o $@ $^ @echo "Built $@ successfully" +$(STATIC_LIB_NAME): $(LIB_OBJ) + $(AR) crs $@ $^ + $(LIB_NAME_MACOS): $(POBJ) g++ -dynamiclib -o $@ $^ @echo "Built $@ successfully"