changeset 6bbb7ae309ac in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=6bbb7ae309ac
description:
        power: Add basic DVFS support for gem5

        Adds DVFS capabilities to gem5, by allowing users to specify lists for
        frequencies and voltages in SrcClockDomains and VoltageDomains 
respectively.
        A separate component, DVFSHandler, provides a small interface to change
        operating points of the associated domains.

        Clock domains will be linked to voltage domains and thus allow separate 
clock,
        but shared voltage lines.

        Currently all the valid performance-level updates are performed with a 
fixed
        transition latency as specified for the domain.

        Config file example:
        ...
        vd = VoltageDomain(voltage = ['1V','0.95V','0.90V','0.85V'])
        tsys.cluster1.clk_domain.clock = ['1GHz','700MHz','400MHz','230MHz']
        tsys.cluster2.clk_domain.clock = ['1GHz','700MHz','400MHz','230MHz']
        tsys.cluster1.clk_domain.domain_id = 0
        tsys.cluster2.clk_domain.domain_id = 1
        tsys.cluster1.clk_domain.voltage_domain = vd
        tsys.cluster2.clk_domain.voltage_domain = vd
        tsys.dvfs_handler.domains = [tsys.cluster1.clk_domain,
                                     tsys.cluster2.clk_domain]
        tsys.dvfs_handler.enable = True

diffstat:

 src/arch/alpha/AlphaSystem.py |    3 +-
 src/arch/mips/MipsSystem.py   |    3 +-
 src/sim/ClockDomain.py        |   23 +++-
 src/sim/DVFSHandler.py        |   68 ++++++++++++
 src/sim/SConscript            |    3 +
 src/sim/System.py             |    5 +
 src/sim/VoltageDomain.py      |   11 +-
 src/sim/clock_domain.cc       |   72 ++++++++++++-
 src/sim/clock_domain.hh       |   91 +++++++++++++++-
 src/sim/dvfs_handler.cc       |  216 +++++++++++++++++++++++++++++++++++++++
 src/sim/dvfs_handler.hh       |  230 ++++++++++++++++++++++++++++++++++++++++++
 src/sim/eventq.hh             |    4 +
 src/sim/voltage_domain.cc     |   92 ++++++++++++++--
 src/sim/voltage_domain.hh     |   96 +++++++++++++----
 14 files changed, 868 insertions(+), 49 deletions(-)

diffs (truncated from 1173 to 300 lines):

diff -r 72277952d444 -r 6bbb7ae309ac src/arch/alpha/AlphaSystem.py
--- a/src/arch/alpha/AlphaSystem.py     Mon Jun 30 13:56:04 2014 -0400
+++ b/src/arch/alpha/AlphaSystem.py     Mon Jun 30 13:56:06 2014 -0400
@@ -45,7 +45,8 @@
     system_type = 34
     system_rev = 1 << 10
 
-    boot_cpu_frequency = 
Param.Frequency(Self.cpu[0].clk_domain.clock.frequency,
+    boot_cpu_frequency = Param.Frequency(Self.cpu[0].clk_domain.clock[0]
+                                         .frequency,
                                          "boot processor frequency")
 
 class FreebsdAlphaSystem(AlphaSystem):
diff -r 72277952d444 -r 6bbb7ae309ac src/arch/mips/MipsSystem.py
--- a/src/arch/mips/MipsSystem.py       Mon Jun 30 13:56:04 2014 -0400
+++ b/src/arch/mips/MipsSystem.py       Mon Jun 30 13:56:06 2014 -0400
@@ -50,7 +50,8 @@
     system_type = 34
     system_rev = 1 << 10
 
-    boot_cpu_frequency = 
Param.Frequency(Self.cpu[0].clk_domain.clock.frequency,
+    boot_cpu_frequency = Param.Frequency(Self.cpu[0].clk_domain.clock[0]
+                                         .frequency,
                                          "boot processor frequency")
 
 class BareIronMipsSystem(MipsSystem):
diff -r 72277952d444 -r 6bbb7ae309ac src/sim/ClockDomain.py
--- a/src/sim/ClockDomain.py    Mon Jun 30 13:56:04 2014 -0400
+++ b/src/sim/ClockDomain.py    Mon Jun 30 13:56:06 2014 -0400
@@ -1,4 +1,4 @@
-# Copyright (c) 2013 ARM Limited
+# Copyright (c) 2013-2014 ARM Limited
 # All rights reserved.
 #
 # The license below extends only to copyright in the software and shall
@@ -35,6 +35,7 @@
 #
 # Authors: Vasileios Spiliopoulos
 #          Akash Bagdia
+#          Stephan Diestelhorst
 
 from m5.params import *
 from m5.SimObject import SimObject
@@ -46,15 +47,31 @@
     cxx_header = "sim/clock_domain.hh"
     abstract = True
 
-# Source clock domain with an actual clock
+# Source clock domain with an actual clock, and a list of voltage and frequency
+# op points
 class SrcClockDomain(ClockDomain):
     type = 'SrcClockDomain'
     cxx_header = "sim/clock_domain.hh"
-    clock = Param.Clock("Clock period")
+
+    # Single clock frequency value, or list of frequencies for DVFS
+    # Frequencies must be ordered in descending order
+    # Note: Matching voltages should be defined in the voltage domain
+    clock = VectorParam.Clock("Clock period")
 
     # A source clock must be associated with a voltage domain
     voltage_domain = Param.VoltageDomain("Voltage domain")
 
+    # Domain ID is an identifier for the DVFS domain as understood by the
+    # necessary control logic (either software or hardware). For example, in
+    # case of software control via cpufreq framework the IDs should correspond
+    # to the neccessary identifier in the device tree blob which is 
interpretted
+    # by the device driver to communicate to the domain controller in hardware.
+    domain_id = Param.Int32(-1, "domain id")
+
+    # Initial performance level from the list of available operation points
+    # Defaults to maximum performance
+    init_perf_level = Param.UInt32(0, "Initial performance level")
+
 # Derived clock domain with a parent clock domain and a frequency
 # divider
 class DerivedClockDomain(ClockDomain):
diff -r 72277952d444 -r 6bbb7ae309ac src/sim/DVFSHandler.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sim/DVFSHandler.py    Mon Jun 30 13:56:06 2014 -0400
@@ -0,0 +1,68 @@
+# Copyright (c) 2013-2014 ARM Limited
+# All rights reserved.
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder.  You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# 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;
+# neither the name of the copyright holders 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
+# OWNER 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: Vasileios Spiliopoulos
+#          Akash Bagdia
+
+from m5.params import *
+from m5.SimObject import SimObject
+from m5.proxy import *
+
+# The handler in its current form is design to be centeralized, one per system
+# and manages all the source clock domains (SrcClockDomain) it is configured to
+# handle.  The specific voltage and frequency points are configured per clock
+# and voltage domain.
+class DVFSHandler(SimObject):
+    type = 'DVFSHandler'
+    cxx_header = "sim/dvfs_handler.hh"
+
+    # List of controllable clock domains which in turn reference the 
appropriate
+    # voltage domains
+    domains = VectorParam.SrcClockDomain([], "list of domains")
+
+    # System domain (its clock and voltage) is not controllable
+    sys_clk_domain = Param.SrcClockDomain(Parent.clk_domain,
+                         "Clk domain in which the handler is instantiated")
+
+    enable = Param.Bool(False, "Enable/Disable the handler")
+
+    # The transition latency depends on how much time the PLLs and voltage
+    # regualators takes to migrate from current levels to the new level, is
+    # usally variable and hardware implementation dependent. In order to
+    # accomodate this effect with ease, we provide a fixed transition latency
+    # associated with all migrations. Configure this to maximum latency that
+    # the hardware will take to migratate between any two perforamnce levels.
+    transition_latency = Param.Latency('100us',
+                             "fixed latency for perf level migration")
diff -r 72277952d444 -r 6bbb7ae309ac src/sim/SConscript
--- a/src/sim/SConscript        Mon Jun 30 13:56:04 2014 -0400
+++ b/src/sim/SConscript        Mon Jun 30 13:56:06 2014 -0400
@@ -36,6 +36,7 @@
 SimObject('ClockDomain.py')
 SimObject('VoltageDomain.py')
 SimObject('System.py')
+SimObject('DVFSHandler.py')
 
 Source('arguments.cc')
 Source('async.cc')
@@ -55,6 +56,7 @@
 Source('clock_domain.cc')
 Source('voltage_domain.cc')
 Source('system.cc')
+Source('dvfs_handler.cc')
 
 if env['TARGET_ISA'] != 'null':
     SimObject('InstTracer.py')
@@ -86,3 +88,4 @@
 DebugFlag('WorkItems')
 DebugFlag('ClockDomain')
 DebugFlag('VoltageDomain')
+DebugFlag('DVFS')
diff -r 72277952d444 -r 6bbb7ae309ac src/sim/System.py
--- a/src/sim/System.py Mon Jun 30 13:56:04 2014 -0400
+++ b/src/sim/System.py Mon Jun 30 13:56:06 2014 -0400
@@ -33,6 +33,7 @@
 from m5.params import *
 from m5.proxy import *
 
+from DVFSHandler import *
 from SimpleMemory import *
 
 class MemoryMode(Enum): vals = ['invalid', 'atomic', 'timing',
@@ -88,3 +89,7 @@
     load_addr_mask = Param.UInt64(0xffffffffff,
             "Address to mask loading binaries with")
     load_offset = Param.UInt64(0, "Address to offset loading binaries with")
+
+    # Dynamic voltage and frequency handler for the system, disabled by default
+    # Provide list of domains that need to be controlled by the handler
+    dvfs_handler = DVFSHandler()
diff -r 72277952d444 -r 6bbb7ae309ac src/sim/VoltageDomain.py
--- a/src/sim/VoltageDomain.py  Mon Jun 30 13:56:04 2014 -0400
+++ b/src/sim/VoltageDomain.py  Mon Jun 30 13:56:06 2014 -0400
@@ -42,6 +42,11 @@
 class VoltageDomain(SimObject):
     type = 'VoltageDomain'
     cxx_header = "sim/voltage_domain.hh"
-    # We use a default voltage of 1V to avoid forcing users to set it
-    # even if they are not interested in using the functionality
-    voltage = Param.Voltage('1V', "Operational voltage")
+
+    # Single or list of voltages for the voltage domain.  If only a single
+    # voltage is specified, it is used for all different frequencies.
+    # Otherwise, the number of specified voltges and frequencies in the clock
+    # domain (src/sim/ClockDomain.py) must match.  Voltages must be specified 
in
+    # descending order. We use a default voltage of 1V to avoid forcing users 
to
+    # set it even if they are not interested in using the functionality
+    voltage = VectorParam.Voltage('1V', "Operational voltage(s)")
diff -r 72277952d444 -r 6bbb7ae309ac src/sim/clock_domain.cc
--- a/src/sim/clock_domain.cc   Mon Jun 30 13:56:04 2014 -0400
+++ b/src/sim/clock_domain.cc   Mon Jun 30 13:56:06 2014 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 ARM Limited
+ * Copyright (c) 2013-2014 ARM Limited
  * Copyright (c) 2013 Cornell University
  * All rights reserved
  *
@@ -39,8 +39,12 @@
  *          Akash Bagdia
  *          Andreas Hansson
  *          Christopher Torng
+ *          Stephan Diestelhorst
  */
 
+#include <algorithm>
+#include <functional>
+
 #include "debug/ClockDomain.hh"
 #include "params/ClockDomain.hh"
 #include "params/DerivedClockDomain.hh"
@@ -70,9 +74,37 @@
 }
 
 SrcClockDomain::SrcClockDomain(const Params *p) :
-    ClockDomain(p, p->voltage_domain)
+    ClockDomain(p, p->voltage_domain),
+    freqOpPoints(p->clock),
+    _domainID(p->domain_id),
+    _perfLevel(p->init_perf_level)
 {
-    clockPeriod(p->clock);
+    VoltageDomain *vdom = p->voltage_domain;
+
+    fatal_if(freqOpPoints.empty(), "DVFS: Empty set of frequencies for "\
+             "domain %d %s\n", _domainID, name());
+
+    fatal_if(!vdom, "DVFS: Empty voltage domain specified for "\
+             "domain %d %s\n", _domainID, name());
+
+    fatal_if((vdom->numVoltages() > 1) &&
+             (vdom->numVoltages() != freqOpPoints.size()),
+             "DVFS: Number of frequency and voltage scaling points do "\
+             "not match: %d:%d ID: %d %s.\n", vdom->numVoltages(),
+             freqOpPoints.size(), _domainID, name());
+
+    // Frequency (& voltage) points should be declared in descending order,
+    // NOTE: Frequency is inverted to ticks, so checking for ascending ticks
+    fatal_if(!std::is_sorted(freqOpPoints.begin(), freqOpPoints.end()),
+             "DVFS: Frequency operation points not in descending order for "\
+             "domain with ID %d\n", _domainID);
+
+    fatal_if(_perfLevel >= freqOpPoints.size(), "DVFS: Initial DVFS point %d "\
+             "is outside of list for Domain ID: %d\n", _perfLevel, _domainID);
+
+    clockPeriod(freqOpPoints[_perfLevel]);
+
+    vdom->registerSrcClockDom(this);
 }
 
 void
@@ -99,6 +131,40 @@
     }
 }
 
+void
+SrcClockDomain::perfLevel(PerfLevel perf_level)
+{
+    assert(validPerfLevel(perf_level));
+
+    DPRINTF(ClockDomain, "DVFS: Switching performance level of domain %s "\
+            "(id: %d) from  %d to %d\n", name(), domainID(), _perfLevel,
+            perf_level);
+
+    _perfLevel = perf_level;
+
+    // Signal the voltage domain that we have changed our perf level so that 
the
+    // voltage domain can recompute its performance level
+    voltageDomain()->sanitiseVoltages();
+
+    // Integrated switching of the actual clock value, too
+    clockPeriod(clkPeriodAtPerfLevel());
+}
+
+void
+SrcClockDomain::serialize(std::ostream &os)
+{
+    SERIALIZE_SCALAR(_perfLevel);
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to