diff --git a/Makefile b/Makefile index a7c0b84..826b202 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,7 @@ # * # */ +include common.mk # Name of the generated binary. BINARY := drampower @@ -56,6 +57,7 @@ LIBSOURCES := $(wildcard src/libdrampower/*.cc) \ src/Parameter.cc\ src/Parametrisable.cc + XMLPARSERSOURCES := $(wildcard src/xmlparser/*.cc) ALLSOURCES := $(wildcard src/cli/*.cc) $(wildcard src/*.cc) $(wildcard src/xmlparser/*.cc) $(wildcard src/libdrampower/*.cc) ALLHEADERS := $(wildcard src/*.h) $(wildcard src/xmlparser/*.h) $(wildcard src/libdrampower/*.h) @@ -67,38 +69,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. @@ -176,6 +152,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..841d531 --- /dev/null +++ b/common.mk @@ -0,0 +1,60 @@ +#/* +# * 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 +# 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/src/CmdHandlers.cc b/src/CmdHandlers.cc index 3480485..52457fc 100644 --- a/src/CmdHandlers.cc +++ b/src/CmdHandlers.cc @@ -376,7 +376,7 @@ void CommandAnalysis::handleSREx(unsigned bank, int64_t timestamp) * * * 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 @@ -395,9 +395,9 @@ void CommandAnalysis::handleSREx(unsigned bank, int64_t timestamp) // self-refresh mode, which excludes the time spent in finishing the // initial auto-refresh. if (sref_cycle_window > sref_cycle + t.RFC) { - sref_cycles_idd6 += zero_guard(timestamp - sref_cycle_window, "sref_cycle_window is in the future."); + sref_cycles += zero_guard(timestamp - sref_cycle_window, "sref_cycle_window is in the future."); } else { - sref_cycles_idd6 += zero_guard(timestamp - sref_cycle - t.RFC, "sref_cycle - t.RFC < 0"); + sref_cycles += zero_guard(timestamp - sref_cycle - t.RFC, "sref_cycle - t.RFC < 0"); } // IDD2N current is consumed when exiting the self-refresh state. @@ -442,7 +442,7 @@ void CommandAnalysis::handleSREx(unsigned bank, int64_t timestamp) * * * 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 @@ -496,7 +496,7 @@ void CommandAnalysis::handleSREx(unsigned bank, int64_t timestamp) * * * 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 @@ -560,7 +560,7 @@ void CommandAnalysis::handleNopEnd(int64_t timestamp) sref_ref_pre_cycles_window = t.RP; sref_cycle_window = sref_cycle + t.RFC; } - sref_cycles_idd6 += zero_guard(timestamp - sref_cycle_window, "sref_cycle_window is in the future"); + sref_cycles += zero_guard(timestamp - sref_cycle_window, "sref_cycle_window is in the future"); } else if (timestamp > sref_cycle + rfc_minus_rp) { if (sref_cycle_window <= sref_cycle + rfc_minus_rp) { diff --git a/src/CommandAnalysis.cc b/src/CommandAnalysis.cc index 08354e1..2c490fb 100644 --- a/src/CommandAnalysis.cc +++ b/src/CommandAnalysis.cc @@ -100,7 +100,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; diff --git a/src/CommandAnalysis.h b/src/CommandAnalysis.h index 4c316a1..b78980e 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;