Skip to content

Commit

Permalink
Merge branch 'master' into refact_ca
Browse files Browse the repository at this point in the history
  • Loading branch information
Sv3n committed Oct 23, 2016
2 parents 533701a + 0540ab9 commit 7e8cba6
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 41 deletions.
29 changes: 2 additions & 27 deletions Makefile
Expand Up @@ -35,6 +35,7 @@
# *
# */

include common.mk

# Name of the generated binary.
BINARY := drampower
Expand All @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -176,6 +152,5 @@ endif
coveragecheckclean:
rm -rf $(LCOV_OUTDIR)

.PHONY: clean pretty test traces

-include $(DEPENDENCIES)
60 changes: 60 additions & 0 deletions 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

12 changes: 6 additions & 6 deletions src/CmdHandlers.cc
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/CommandAnalysis.cc
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/CommandAnalysis.h
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/MemoryPowerModel.cc
Expand Up @@ -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;

Expand Down Expand Up @@ -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<double>(c.sref_cycles_idd6), static_cast<double>(c.sref_ref_act_cycles),
static_cast<double>(c.sref_cycles), static_cast<double>(c.sref_ref_act_cycles),
static_cast<double>(c.sref_ref_pre_cycles), static_cast<double>(c.spup_ref_act_cycles),
static_cast<double>(c.spup_ref_pre_cycles), t.clkPeriod);

Expand Down Expand Up @@ -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<double>(c.sref_cycles_idd6), static_cast<double>(c.sref_ref_act_cycles),
static_cast<double>(c.sref_cycles), static_cast<double>(c.sref_ref_act_cycles),
static_cast<double>(c.sref_ref_pre_cycles), static_cast<double>(c.spup_ref_act_cycles),
static_cast<double>(c.spup_ref_pre_cycles), t.clkPeriod);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7e8cba6

Please sign in to comment.