111424Sdavid.guillen@arm.com# Copyright (c) 2016 ARM Limited 211424Sdavid.guillen@arm.com# All rights reserved 311424Sdavid.guillen@arm.com# 411424Sdavid.guillen@arm.com# The license below extends only to copyright in the software and shall 511424Sdavid.guillen@arm.com# not be construed as granting a license to any other intellectual 611424Sdavid.guillen@arm.com# property including but not limited to intellectual property relating 711424Sdavid.guillen@arm.com# to a hardware implementation of the functionality of the software 811424Sdavid.guillen@arm.com# licensed hereunder. You may use the software subject to the license 911424Sdavid.guillen@arm.com# terms below provided that you ensure that this notice is replicated 1011424Sdavid.guillen@arm.com# unmodified and in its entirety in all distributions of the software, 1111424Sdavid.guillen@arm.com# modified or unmodified, in source code or in binary form. 1211424Sdavid.guillen@arm.com# 1311424Sdavid.guillen@arm.com# Redistribution and use in source and binary forms, with or without 1411424Sdavid.guillen@arm.com# modification, are permitted provided that the following conditions are 1511424Sdavid.guillen@arm.com# met: redistributions of source code must retain the above copyright 1611424Sdavid.guillen@arm.com# notice, this list of conditions and the following disclaimer; 1711424Sdavid.guillen@arm.com# redistributions in binary form must reproduce the above copyright 1811424Sdavid.guillen@arm.com# notice, this list of conditions and the following disclaimer in the 1911424Sdavid.guillen@arm.com# documentation and/or other materials provided with the distribution; 2011424Sdavid.guillen@arm.com# neither the name of the copyright holders nor the names of its 2111424Sdavid.guillen@arm.com# contributors may be used to endorse or promote products derived from 2211424Sdavid.guillen@arm.com# this software without specific prior written permission. 2311424Sdavid.guillen@arm.com# 2411424Sdavid.guillen@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2511424Sdavid.guillen@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2611424Sdavid.guillen@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2711424Sdavid.guillen@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2811424Sdavid.guillen@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2911424Sdavid.guillen@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3011424Sdavid.guillen@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3111424Sdavid.guillen@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3211424Sdavid.guillen@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3311424Sdavid.guillen@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3411424Sdavid.guillen@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3511424Sdavid.guillen@arm.com# 3611424Sdavid.guillen@arm.com# Author: David Guillen Fandos 3711424Sdavid.guillen@arm.com 3811424Sdavid.guillen@arm.com/*! \page gem5PowerModel Gem5 Power & Thermal model 3911424Sdavid.guillen@arm.com 4011424Sdavid.guillen@arm.com \tableofcontents 4111424Sdavid.guillen@arm.com 4211424Sdavid.guillen@arm.com This document gives an overview of the power and thermal modelling 4311424Sdavid.guillen@arm.com infrastructure in Gem5. The purpose is to give a high level view of 4411424Sdavid.guillen@arm.com all the pieces involved and how they interact with each other and 4511424Sdavid.guillen@arm.com the simulator. 4611424Sdavid.guillen@arm.com 4711424Sdavid.guillen@arm.com \section gem5_PM_CD Class overview 4811424Sdavid.guillen@arm.com 4911424Sdavid.guillen@arm.com Classes involved in the power model are: 5011424Sdavid.guillen@arm.com 5111424Sdavid.guillen@arm.com - PowerModel: Represents a power model for a hardware component. 5211424Sdavid.guillen@arm.com 5311424Sdavid.guillen@arm.com - PowerModelState: Represents a power model for a hardware component 5411424Sdavid.guillen@arm.com in a certain power state. It is an abstract class that defines an 5511424Sdavid.guillen@arm.com interface that must be implemented for each model. 5611424Sdavid.guillen@arm.com 5711424Sdavid.guillen@arm.com - MathExprPowerModel: Simple implementation of PowerModelState that 5811424Sdavid.guillen@arm.com assumes that power can be modeled using a simple power 5911424Sdavid.guillen@arm.com 6011424Sdavid.guillen@arm.com Classes involved in the thermal model are: 6111424Sdavid.guillen@arm.com 6211424Sdavid.guillen@arm.com - ThermalModel: Contains the system thermal model logic and state. 6311424Sdavid.guillen@arm.com It performs the power query and temperature update. It also enables 6411424Sdavid.guillen@arm.com gem5 to query for temperature (for OS reporting). 6511424Sdavid.guillen@arm.com 6611424Sdavid.guillen@arm.com - ThermalDomain: Represents an entity that generates heat. It's 6711424Sdavid.guillen@arm.com essentially a group of SimObjects grouped under a SubSystem component 6811424Sdavid.guillen@arm.com that have its own thermal behaviour. 6911424Sdavid.guillen@arm.com 7011424Sdavid.guillen@arm.com - ThermalNode: Represents a node in the thermal circuital equivalent. 7111424Sdavid.guillen@arm.com The node has a temperature and interacts with other nodes through 7211424Sdavid.guillen@arm.com connections (thermal resistors and capacitors). 7311424Sdavid.guillen@arm.com 7411424Sdavid.guillen@arm.com - ThermalReference: Temperature reference for the thermal model 7511424Sdavid.guillen@arm.com (essentially a thermal node with a fixed temperature), can be used 7611424Sdavid.guillen@arm.com to model air or any other constant temperature domains. 7711424Sdavid.guillen@arm.com 7811424Sdavid.guillen@arm.com - ThermalEntity: A thermal component that connects two thermal nodes 7911424Sdavid.guillen@arm.com and models a thermal impedance between them. This class is just an 8011424Sdavid.guillen@arm.com abstract interface. 8111424Sdavid.guillen@arm.com 8211424Sdavid.guillen@arm.com - ThermalResistor: Implements ThermalEntity to model a thermal resistance 8311424Sdavid.guillen@arm.com between the two nodes it connects. Thermal resistances model the 8411424Sdavid.guillen@arm.com capacity of a material to transfer heat (units in K/W). 8511424Sdavid.guillen@arm.com 8611424Sdavid.guillen@arm.com - ThermalCapacitor. Implements ThermalEntity to model a thermal 8711424Sdavid.guillen@arm.com capacitance. Thermal capacitors are used to model material's thermal 8811424Sdavid.guillen@arm.com capacitance, this is, the ability to change a certain material 8911424Sdavid.guillen@arm.com temperature (units in J/K). 9011424Sdavid.guillen@arm.com 9111424Sdavid.guillen@arm.com \section gem5_thermal Thermal model 9211424Sdavid.guillen@arm.com 9311424Sdavid.guillen@arm.com The thermal model works by creating a circuital equivalent of the 9411424Sdavid.guillen@arm.com simulated platform. Each node in the circuit has a temperature (as 9511424Sdavid.guillen@arm.com voltage equivalent) and power flows between nodes (as current in a 9611424Sdavid.guillen@arm.com circuit). 9711424Sdavid.guillen@arm.com 9811424Sdavid.guillen@arm.com To build this equivalent temperature model the platform is required 9911424Sdavid.guillen@arm.com to group the power actors (any component that has a power model) 10011424Sdavid.guillen@arm.com under SubSystems and attach ThermalDomains to those subsystems. 10111424Sdavid.guillen@arm.com Other components might also be created (like ThermalReferences) and 10211424Sdavid.guillen@arm.com connected all together by creating thermal entities (capacitors and 10311424Sdavid.guillen@arm.com resistors). 10411424Sdavid.guillen@arm.com 10511424Sdavid.guillen@arm.com Last step to conclude the thermal model is to create the ThermalModel 10611424Sdavid.guillen@arm.com instance itself and attach all the instances used to it, so it can 10711424Sdavid.guillen@arm.com properly update them at runtime. Only one thermal model instance is 10811424Sdavid.guillen@arm.com supported right now and it will automatically report temperature when 10911424Sdavid.guillen@arm.com appropriate (ie. platform sensor devices). 11011424Sdavid.guillen@arm.com 11111424Sdavid.guillen@arm.com \section gem5_power Power model 11211424Sdavid.guillen@arm.com 11311424Sdavid.guillen@arm.com Every ClockedObject has a power model associated. If this power model is 11411424Sdavid.guillen@arm.com non-null power will be calculated at every stats dump (although it might 11511424Sdavid.guillen@arm.com be possible to force power evaluation at any other point, if the power 11611424Sdavid.guillen@arm.com model uses the stats, it is a good idea to keep both events in sync). 11711424Sdavid.guillen@arm.com The definition of a power model is quite vague in the sense that it is 11811424Sdavid.guillen@arm.com as flexible as users want it to be. The only enforced contraints so far 11911424Sdavid.guillen@arm.com is the fact that a power model has several power state models, one for 12011424Sdavid.guillen@arm.com each possible power state for that hardware block. When it comes to compute 12111424Sdavid.guillen@arm.com power consumption the power is just the weighted average of each power model. 12211424Sdavid.guillen@arm.com 12311424Sdavid.guillen@arm.com A power state model is essentially an interface that allows us to define two 12411424Sdavid.guillen@arm.com power functions for dynamic and static. As an example implementation a class 12511424Sdavid.guillen@arm.com called MathExprPowerModel has been provided. This implementation allows the 12611424Sdavid.guillen@arm.com user to define a power model as an equation involving several statistics. 12711424Sdavid.guillen@arm.com There's also some automatic (or "magic") variables such as "temp", which 12811424Sdavid.guillen@arm.com reports temperature. 12912678Sjason@lowepower.com*/ 130