From 12cccdb9fe37411898714faabf6f95dc295af85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Thu, 13 Oct 2016 14:09:00 +0200 Subject: [PATCH 1/4] Makefiles improved. --- Makefile | 28 +--------------------------- common.mk | 23 +++++++++++++++++++++++ test/libdrampowertest/Makefile | 31 ++++++------------------------- 3 files changed, 30 insertions(+), 52 deletions(-) create mode 100644 common.mk diff --git a/Makefile b/Makefile index 86ce23e..b140e5f 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,7 @@ # * # */ +include common.mk # Name of the generated binary. BINARY := drampower @@ -56,38 +57,12 @@ ALLOBJECTS := ${ALLSOURCES:.cc=.o} DEPENDENCIES := ${ALLSOURCES:.cc=.d} -########################################## -# Compiler settings -########################################## - -# State what compiler we use. -CXX ?= g++ - -ifeq ($(COVERAGE),1) - GCOVFLAGS := -fprofile-arcs -ftest-coverage -else - GCOVFLAGS := -endif - -# Optimization flags. Usually you should not optimize until you have finished -# debugging, except when you want to detect dead code. -OPTCXXFLAGS ?= - -# Debugging flags. -DBGCXXFLAGS ?= -g ${GCOVFLAGS} - -# Warning flags -WARNFLAGS := -W -pedantic-errors -Wextra -Werror \ - -Wformat -Wformat-nonliteral -Wpointer-arith \ - -Wcast-align -Wconversion -Wall -Werror - # Warning flags for deprecated files DEPWARNFLAGS := -W -pedantic-errors -Wextra -Werror \ -Wformat -Wformat-nonliteral -Wpointer-arith \ -Wcast-align -Wall -Werror # Sum up the flags. -CXXFLAGS := -O ${WARNFLAGS} ${DBGCXXFLAGS} ${OPTCXXFLAGS} -std=c++0x DEPCXXFLAGS := -O ${DEPWARNFLAGS} ${DBGCXXFLAGS} ${OPTCXXFLAGS} -std=c++0x # Linker flags. @@ -165,6 +140,5 @@ endif coveragecheckclean: rm -rf $(LCOV_OUTDIR) -.PHONY: clean pretty test traces -include $(DEPENDENCIES) diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..6757e82 --- /dev/null +++ b/common.mk @@ -0,0 +1,23 @@ +.PHONY: clean pretty test traces + +# CXX is a predefined variable of GNU Make. Thus, the conditional assignment +# here may not take effect. If you want to force another compiler here use +# ':=' instead of '?='. +CXX ?= g++ + +ifeq ($(COVERAGE),1) + GCOVFLAGS := -fprofile-arcs -ftest-coverage +else + GCOVFLAGS := +endif + +# Debugging flags. +DBGCXXFLAGS ?= -g ${GCOVFLAGS} + +# Warning flags +WARNFLAGS := -W -pedantic-errors -Wextra -Werror \ + -Wformat -Wformat-nonliteral -Wpointer-arith \ + -Wcast-align -Wconversion -Wall -Werror + +CXXFLAGS := -O ${WARNFLAGS} ${DBGCXXFLAGS} ${OPTCXXFLAGS} -std=c++0x + diff --git a/test/libdrampowertest/Makefile b/test/libdrampowertest/Makefile index d7f76a2..7cef9ad 100644 --- a/test/libdrampowertest/Makefile +++ b/test/libdrampowertest/Makefile @@ -33,35 +33,17 @@ # Authors: Matthias Jung, Omar Naji, Sven Goossens # -ifeq ($(COVERAGE),1) - GCOVFLAGS := -fprofile-arcs -ftest-coverage -else - GCOVFLAGS := -endif - -# Optimization flags. Usually you should not optimize until you have finished -# debugging, except when you want to detect dead code. -OPTCXXFLAGS ?= - -# Debugging flags. -DBGCXXFLAGS ?= -g ${GCOVFLAGS} - -# Common warning flags shared by both C and C++. -WARNFLAGS := -W -pedantic-errors -Wextra -Werror \ - -Wformat -Wformat-nonliteral -Wpointer-arith \ - -Wcast-align -Wconversion -Wall -Werror - -# Sum up the flags. -CXXFLAGS := -O ${WARNFLAGS} ${DBGCXXFLAGS} ${OPTCXXFLAGS} -std=c++0x - DRAMPOWER_PATH ?= ../.. MYPATH := ${DRAMPOWER_PATH}/test/libdrampowertest -USE_XERCES ?= 1 + +include ${DRAMPOWER_PATH}/common.mk # Name of the generated binary. BINARY := ${MYPATH}/library_test BINARY2 := ${MYPATH}/window_example +USE_XERCES ?= 1 + ifeq ($(USE_XERCES),1) LIBS := -lxerces-c -ldrampowerxml -ldrampower else @@ -69,8 +51,8 @@ else endif all: - g++ ${MYPATH}/lib_test.cc ${CXXFLAGS} -iquote ${DRAMPOWER_PATH}/src -DUSE_XERCES=${USE_XERCES} -L${DRAMPOWER_PATH}/src/ ${LIBS} -o $(BINARY) - g++ ${MYPATH}/window_example.cc ${CXXFLAGS} -iquote ${DRAMPOWER_PATH}/src -DUSE_XERCES=${USE_XERCES} -L${DRAMPOWER_PATH}/src/ ${LIBS} -o $(BINARY2) + $(CXX) ${MYPATH}/lib_test.cc ${CXXFLAGS} -iquote ${DRAMPOWER_PATH}/src -DUSE_XERCES=${USE_XERCES} -L${DRAMPOWER_PATH}/src/ ${LIBS} -o $(BINARY) + $(CXX) ${MYPATH}/window_example.cc ${CXXFLAGS} -iquote ${DRAMPOWER_PATH}/src -DUSE_XERCES=${USE_XERCES} -L${DRAMPOWER_PATH}/src/ ${LIBS} -o $(BINARY2) clean: rm -f $(BINARY) @@ -83,4 +65,3 @@ test: all ./$(BINARY) ${DRAMPOWER_PATH}/memspecs/MICRON_1Gb_DDR2-1066_16bit_H.xml ./$(BINARY2) ${DRAMPOWER_PATH}/memspecs/MICRON_1Gb_DDR2-1066_16bit_H.xml -.PHONY: clean test From 1adaf23e82d610041595bdfd4827a6ba76ee20ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Thu, 13 Oct 2016 14:21:58 +0200 Subject: [PATCH 2/4] License header added to file --- common.mk | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/common.mk b/common.mk index 6757e82..841d531 100644 --- a/common.mk +++ b/common.mk @@ -1,3 +1,40 @@ +#/* +# * Copyright (c) 2012-2014, TU Delft +# * Copyright (c) 2012-2014, TU Eindhoven +# * Copyright (c) 2012-2014, TU Kaiserslautern +# * All rights reserved. +# * +# * Redistribution and use in source and binary forms, with or without +# * modification, are permitted provided that the following conditions are +# * met: +# * +# * 1. Redistributions of source code must retain the above copyright +# * notice, this list of conditions and the following disclaimer. +# * +# * 2. Redistributions in binary form must reproduce the above copyright +# * notice, this list of conditions and the following disclaimer in the +# * documentation and/or other materials provided with the distribution. +# * +# * 3. Neither the name of the copyright holder nor the names of its +# * contributors may be used to endorse or promote products derived from +# * this software without specific prior written permission. +# * +# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# * +# * Authors: Karthik Chandrasekar, Benny Akesson, Sven Goossens +# * +# */ + .PHONY: clean pretty test traces # CXX is a predefined variable of GNU Make. Thus, the conditional assignment From 0765a718e8dc7440f33a60069d5843b991c82ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Tue, 18 Oct 2016 00:48:57 +0200 Subject: [PATCH 3/4] sref_cycles_idd6 renamed back to sref_cycles. The suffix does not add significant information and may cause confusion. Besides, supposing a bank-wise self-refresh the current drawn for a bank in self-refresh mode would probably be different from IDD6. --- src/CommandAnalysis.cc | 14 +++++++------- src/CommandAnalysis.h | 2 +- src/MemoryPowerModel.cc | 12 ++++++------ src/MemoryPowerModel.h | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/CommandAnalysis.cc b/src/CommandAnalysis.cc index e8085b4..961faa5 100644 --- a/src/CommandAnalysis.cc +++ b/src/CommandAnalysis.cc @@ -97,7 +97,7 @@ void CommandAnalysis::clearStats(const int64_t timestamp) s_pre_pdcycles = 0; pup_act_cycles = 0; pup_pre_cycles = 0; - sref_cycles_idd6 = 0; + sref_cycles = 0; spup_cycles = 0; sref_ref_act_cycles = 0; sref_ref_pre_cycles = 0; @@ -531,7 +531,7 @@ void CommandAnalysis::evaluate(const MemorySpecification& memSpec, * * * Summary: - * sref_cycles_idd6 += tSREF – tRFC + * sref_cycles += tSREF – tRFC * sref_ref_act_cycles += tRFC - tRP * sref_ref_pre_cycles += tRP * spup_ref_act_cycles += 0 @@ -550,9 +550,9 @@ void CommandAnalysis::evaluate(const MemorySpecification& memSpec, // self-refresh mode, which excludes the time spent in finishing the // initial auto-refresh. if (sref_cycle_window > sref_cycle + memSpec.memTimingSpec.RFC) { - sref_cycles_idd6 += max(zero, timestamp - sref_cycle_window); + sref_cycles += max(zero, timestamp - sref_cycle_window); } else { - sref_cycles_idd6 += max(zero, timestamp - sref_cycle + sref_cycles += max(zero, timestamp - sref_cycle - memSpec.memTimingSpec.RFC); } @@ -603,7 +603,7 @@ void CommandAnalysis::evaluate(const MemorySpecification& memSpec, * * * Summary: - * sref_cycles_idd6 += 0 + * sref_cycles += 0 * sref_ref_act_cycles += tRFC - tRP * sref_ref_pre_cycles += tSREF – (tRFC – tRP) * spup_ref_act_cycles += 0 @@ -662,7 +662,7 @@ void CommandAnalysis::evaluate(const MemorySpecification& memSpec, * * * Summary: - * sref_cycles_idd6 += 0 + * sref_cycles += 0 * sref_ref_act_cycles += tSREF * sref_ref_pre_cycles += 0 * spup_ref_act_cycles += (tRFC – tRP) - tSREF @@ -726,7 +726,7 @@ void CommandAnalysis::evaluate(const MemorySpecification& memSpec, sref_ref_pre_cycles_window = memSpec.memTimingSpec.RP; sref_cycle_window = sref_cycle + memSpec.memTimingSpec.RFC; } - sref_cycles_idd6 += max(zero, timestamp - sref_cycle_window); + sref_cycles += max(zero, timestamp - sref_cycle_window); } else if (timestamp > sref_cycle + (memSpec.memTimingSpec.RFC - memSpec.memTimingSpec.RP)) { if(sref_cycle_window <= sref_cycle + (memSpec.memTimingSpec.RFC - memSpec.memTimingSpec.RP)) { sref_ref_act_cycles += (memSpec.memTimingSpec.RFC - memSpec.memTimingSpec.RP) - sref_ref_act_cycles_window; diff --git a/src/CommandAnalysis.h b/src/CommandAnalysis.h index 104912c..589e82c 100644 --- a/src/CommandAnalysis.h +++ b/src/CommandAnalysis.h @@ -99,7 +99,7 @@ class CommandAnalysis { int64_t s_pre_pdcycles; // Number of clock cycles in self-refresh mode (excludes the initial // auto-refresh). During this time the current drawn is IDD6. - int64_t sref_cycles_idd6; + int64_t sref_cycles; // Number of clock cycles in activate power-up mode int64_t pup_act_cycles; // Number of clock cycles in precharged power-up mode diff --git a/src/MemoryPowerModel.cc b/src/MemoryPowerModel.cc index cfd1dda..630bb73 100644 --- a/src/MemoryPowerModel.cc +++ b/src/MemoryPowerModel.cc @@ -146,7 +146,7 @@ void MemoryPowerModel::power_calc(const MemorySpecification& memSpec, window_cycles = c.actcycles + c.precycles + c.f_act_pdcycles + c.f_pre_pdcycles + - c.s_act_pdcycles + c.s_pre_pdcycles + c.sref_cycles_idd6 + c.s_act_pdcycles + c.s_pre_pdcycles + c.sref_cycles + c.sref_ref_act_cycles + c.sref_ref_pre_cycles + c.spup_ref_act_cycles + c.spup_ref_pre_cycles; @@ -175,7 +175,7 @@ void MemoryPowerModel::power_calc(const MemorySpecification& memSpec, // self-refresh cycles energy including a refresh per self-refresh entry energy.sref_energy = engy_sref(mps.idd6, mps.idd3n, mps.idd5, mps.vdd, - static_cast(c.sref_cycles_idd6), static_cast(c.sref_ref_act_cycles), + static_cast(c.sref_cycles), static_cast(c.sref_ref_act_cycles), static_cast(c.sref_ref_pre_cycles), static_cast(c.spup_ref_act_cycles), static_cast(c.spup_ref_pre_cycles), t.clkPeriod); @@ -221,7 +221,7 @@ void MemoryPowerModel::power_calc(const MemorySpecification& memSpec, energy.sref_energy += engy_sref(mps.idd62, mps.idd3n2, mps.idd52, mps.vdd2, - static_cast(c.sref_cycles_idd6), static_cast(c.sref_ref_act_cycles), + static_cast(c.sref_cycles), static_cast(c.sref_ref_act_cycles), static_cast(c.sref_ref_pre_cycles), static_cast(c.spup_ref_act_cycles), static_cast(c.spup_ref_pre_cycles), t.clkPeriod); @@ -307,7 +307,7 @@ void MemoryPowerModel::power_print(const MemorySpecification& memSpec, int term, << endl << " #Auto-Refresh Precharged cycles during Self-Refresh: " << c.sref_ref_pre_cycles << endl << "#Auto-Refresh Cycles: " << c.numberofrefs * memTimingSpec.RFC << endl << "#Self-Refreshes: " << c.numberofsrefs - << endl << "#Self-Refresh Cycles: " << c.sref_cycles_idd6 + << endl << "#Self-Refresh Cycles: " << c.sref_cycles << endl << "----------------------------------------" << endl << "Total Trace Length (clock cycles): " << total_cycles << endl << "----------------------------------------" << endl; @@ -364,13 +364,13 @@ void MemoryPowerModel::power_print(const MemorySpecification& memSpec, int term, // Self-refresh active energy estimation (not including background energy) double MemoryPowerModel::engy_sref(double idd6, double idd3n, double idd5, - double vdd, double sref_cycles_idd6, double sref_ref_act_cycles, + double vdd, double sref_cycles, double sref_ref_act_cycles, double sref_ref_pre_cycles, double spup_ref_act_cycles, double spup_ref_pre_cycles, double clk) { double sref_energy; - sref_energy = ((idd6 * sref_cycles_idd6) + ((idd5 - idd3n) * (sref_ref_act_cycles + sref_energy = ((idd6 * sref_cycles) + ((idd5 - idd3n) * (sref_ref_act_cycles + spup_ref_act_cycles + sref_ref_pre_cycles + spup_ref_pre_cycles))) * vdd * clk; return sref_energy; diff --git a/src/MemoryPowerModel.h b/src/MemoryPowerModel.h index 0818155..9010beb 100644 --- a/src/MemoryPowerModel.h +++ b/src/MemoryPowerModel.h @@ -58,7 +58,7 @@ class MemoryPowerModel { double idd3n, double idd5, double vdd, - double sref_cycles_idd6, + double sref_cycles, double sref_ref_act_cycles, double sref_ref_pre_cycles, double spup_ref_act_cycles, From 0b734e7bb94987d703accf89e2494d1f0c2d4bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Tue, 18 Oct 2016 01:07:06 +0200 Subject: [PATCH 4/4] Typo fixed. --- test/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.py b/test/test.py index 8af2a1e..dffa261 100644 --- a/test/test.py +++ b/test/test.py @@ -169,7 +169,7 @@ def test_libdrampower_output_matches_reference(self): self.assertListEqual(new, ref) def test_window_example(self): - """ libdrampower-based window example output should match drampower output for LPDDR2-1066 with the window command trace """ + """ libdrampower-based window example output should match drampower output for DDR2-1066 with the window command trace """ self.buildLibDRAMPowerExecutables() with open(self.tempFileName, 'w') as f: self.assertEqual(subprocess.call(['./drampower', '-m', 'memspecs/MICRON_1Gb_DDR2-1066_16bit_H.xml', '-c', TestLibDRAMPower.testPath + '/window.trace'], stdout=f), 0)