mathexpr_powermodel.hh revision 11800
12SN/A/* 21762SN/A * Copyright (c) 2016 ARM Limited 32SN/A * All rights reserved 42SN/A * 52SN/A * The license below extends only to copyright in the software and shall 62SN/A * not be construed as granting a license to any other intellectual 72SN/A * property including but not limited to intellectual property relating 82SN/A * to a hardware implementation of the functionality of the software 92SN/A * licensed hereunder. You may use the software subject to the license 102SN/A * terms below provided that you ensure that this notice is replicated 112SN/A * unmodified and in its entirety in all distributions of the software, 122SN/A * modified or unmodified, in source code or in binary form. 132SN/A * 142SN/A * Redistribution and use in source and binary forms, with or without 152SN/A * modification, are permitted provided that the following conditions are 162SN/A * met: redistributions of source code must retain the above copyright 172SN/A * notice, this list of conditions and the following disclaimer; 182SN/A * redistributions in binary form must reproduce the above copyright 192SN/A * notice, this list of conditions and the following disclaimer in the 202SN/A * documentation and/or other materials provided with the distribution; 212SN/A * neither the name of the copyright holders nor the names of its 222SN/A * contributors may be used to endorse or promote products derived from 232SN/A * this software without specific prior written permission. 242SN/A * 252SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 262SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 272665Ssaidi@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 282665Ssaidi@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 292665Ssaidi@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 302SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 312SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 322SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 332SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 342SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 352SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 362SN/A * 372SN/A * Authors: David Guillen Fandos 382SN/A */ 392SN/A 402SN/A#ifndef __SIM_MATHEXPR_POWERMODEL_PM_HH__ 412SN/A#define __SIM_MATHEXPR_POWERMODEL_PM_HH__ 422SN/A 432SN/A#include <unordered_map> 4456SN/A 451127SN/A#include "params/MathExprPowerModel.hh" 462SN/A#include "sim/mathexpr.hh" 472797Sktlim@umich.edu#include "sim/power/power_model.hh" 482797Sktlim@umich.edu 492609SN/Anamespace Stats { 502SN/A class Info; 512SN/A} 522SN/A 532SN/A/** 542SN/A * A Equation power model. The power is represented as a combination 551127SN/A * of some stats and automatic variables (like temperature). 562SN/A */ 571553SN/Aclass MathExprPowerModel : public PowerModelState 581553SN/A{ 591553SN/A public: 601553SN/A 611553SN/A typedef MathExprPowerModelParams Params; 622797Sktlim@umich.edu MathExprPowerModel(const Params *p); 632797Sktlim@umich.edu 642797Sktlim@umich.edu /** 652839Sktlim@umich.edu * Get the dynamic power consumption. 662839Sktlim@umich.edu * 672839Sktlim@umich.edu * @return Power (Watts) consumed by this object (dynamic component) 682797Sktlim@umich.edu */ 692797Sktlim@umich.edu double getDynamicPower() const { 70265SN/A return dyn_expr.eval( 711553SN/A std::bind(&MathExprPowerModel::getStatValue, 722797Sktlim@umich.edu this, std::placeholders::_1) 732797Sktlim@umich.edu ); 742797Sktlim@umich.edu } 751553SN/A 761553SN/A /** 771553SN/A * Get the static power consumption. 78265SN/A * 792797Sktlim@umich.edu * @return Power (Watts) consumed by this object (static component) 802797Sktlim@umich.edu */ 812SN/A double getStaticPower() const { 822SN/A return st_expr.eval( 832SN/A std::bind(&MathExprPowerModel::getStatValue, 842SN/A this, std::placeholders::_1) 852SN/A ); 862SN/A } 872SN/A 881553SN/A /** 892SN/A * Get the value for a variable (maps to a stat) 902SN/A * 912SN/A * @param name Name of the variable to retrieve the value from 922SN/A * 931553SN/A * @return Power (Watts) consumed by this object (static component) 94265SN/A */ 951127SN/A double getStatValue(const std::string & name) const; 961127SN/A 97465SN/A void startup(); 982499SN/A 99465SN/A void regStats(); 1002499SN/A 101465SN/A private: 1022SN/A 1032SN/A // Math expressions for dynamic and static power 1042SN/A MathExpr dyn_expr, st_expr; 105330SN/A 1062SN/A // Basename of the object in the gem5 stats hierachy 1072SN/A std::string basename; 1082SN/A 1092SN/A // Map that contains relevant stats for this power model 110330SN/A std::unordered_map<std::string, Stats::Info*> stats_map; 111330SN/A}; 112330SN/A 113395SN/A#endif 114395SN/A