QoSPolicy.py revision 13023:a379876f2244
12391SN/A# Copyright (c) 2018 ARM Limited 22391SN/A# All rights reserved. 32391SN/A# 42391SN/A# The license below extends only to copyright in the software and shall 52391SN/A# not be construed as granting a license to any other intellectual 62391SN/A# property including but not limited to intellectual property relating 72391SN/A# to a hardware implementation of the functionality of the software 82391SN/A# licensed hereunder. You may use the software subject to the license 92391SN/A# terms below provided that you ensure that this notice is replicated 102391SN/A# unmodified and in its entirety in all distributions of the software, 112391SN/A# modified or unmodified, in source code or in binary form. 122391SN/A# 132391SN/A# Redistribution and use in source and binary forms, with or without 142391SN/A# modification, are permitted provided that the following conditions are 152391SN/A# met: redistributions of source code must retain the above copyright 162391SN/A# notice, this list of conditions and the following disclaimer; 172391SN/A# redistributions in binary form must reproduce the above copyright 182391SN/A# notice, this list of conditions and the following disclaimer in the 192391SN/A# documentation and/or other materials provided with the distribution; 202391SN/A# neither the name of the copyright holders nor the names of its 212391SN/A# contributors may be used to endorse or promote products derived from 222391SN/A# this software without specific prior written permission. 232391SN/A# 242391SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 252391SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 262391SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 272665Ssaidi@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 282665Ssaidi@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 292914Ssaidi@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 302391SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 312391SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 322391SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 332391SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 342391SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 352391SN/A# 362391SN/A# Authors: Giacomo Travaglini 372391SN/A 382391SN/Afrom m5.SimObject import * 392391SN/Afrom m5.params import * 402391SN/A 412391SN/A# QoS scheduler policy used to serve incoming transaction 423348Sbinkertn@umich.educlass QoSPolicy(SimObject): 432391SN/A type = 'QoSPolicy' 442391SN/A abstract = True 453879Ssaidi@eecs.umich.edu cxx_header = "mem/qos/policy.hh" 462394SN/A cxx_class = 'QoS::Policy' 472391SN/A 482415SN/Aclass QoSFixedPriorityPolicy(QoSPolicy): 493348Sbinkertn@umich.edu type = 'QoSFixedPriorityPolicy' 502394SN/A cxx_header = "mem/qos/policy_fixed_prio.hh" 512391SN/A cxx_class = 'QoS::FixedPriorityPolicy' 522423SN/A 532391SN/A cxx_exports = [ 543012Ssaidi@eecs.umich.edu PyBindMethod('initMasterName'), 554467Sstever@eecs.umich.edu PyBindMethod('initMasterObj'), 562391SN/A ] 573012Ssaidi@eecs.umich.edu 582391SN/A _mpriorities = None 592391SN/A 602391SN/A def setMasterPriority(self, master, priority): 613012Ssaidi@eecs.umich.edu if not self._mpriorities: 623918Ssaidi@eecs.umich.edu self._mpriorities = [] 632391SN/A 643012Ssaidi@eecs.umich.edu self._mpriorities.append([master, priority]) 652391SN/A 662391SN/A def init(self): 672391SN/A if not self._mpriorities: 682391SN/A print("Error, use setMasterPriority to init masters/priorities\n"); 693751Sgblack@eecs.umich.edu exit(1) 703751Sgblack@eecs.umich.edu else: 713751Sgblack@eecs.umich.edu for mprio in self._mpriorities: 723751Sgblack@eecs.umich.edu master = mprio[0] 733012Ssaidi@eecs.umich.edu priority = mprio[1] 742391SN/A if isinstance(master, basestring): 752391SN/A self.getCCObject().initMasterName( 762541SN/A master, int(priority)) 772541SN/A else: 782541SN/A self.getCCObject().initMasterObj( 794470Sstever@eecs.umich.edu master.getCCObject(), priority) 804470Sstever@eecs.umich.edu 814470Sstever@eecs.umich.edu # default fixed priority value for non-listed Masters 824470Sstever@eecs.umich.edu qos_fixed_prio_default_prio = Param.UInt8(0, 834467Sstever@eecs.umich.edu "Default priority for non-listed Masters") 844467Sstever@eecs.umich.edu 854467Sstever@eecs.umich.educlass QoSPropFairPolicy(QoSPolicy): 864467Sstever@eecs.umich.edu type = 'QoSPropFairPolicy' 872541SN/A cxx_header = "mem/qos/policy_pf.hh" 882541SN/A cxx_class = 'QoS::PropFairPolicy' 892391SN/A 902391SN/A cxx_exports = [ 913012Ssaidi@eecs.umich.edu PyBindMethod('initMasterName'), 923918Ssaidi@eecs.umich.edu PyBindMethod('initMasterObj'), 932416SN/A ] 942391SN/A 952391SN/A _mscores = None 962391SN/A 972391SN/A def setInitialScore(self, master, score): 982391SN/A if not self._mscores: 993012Ssaidi@eecs.umich.edu self._mscores = [] 1004040Ssaidi@eecs.umich.edu 1012391SN/A self._mscores.append([master, score]) 1023012Ssaidi@eecs.umich.edu 1032391SN/A def init(self): 1042391SN/A if not self._mscores: 1052391SN/A print("Error, use setInitialScore to init masters/scores\n"); 1062408SN/A exit(1) 1072408SN/A else: 1082408SN/A for mprio in self._mscores: 1092409SN/A master = mprio[0] 1102409SN/A score = mprio[1] 1112408SN/A if isinstance(master, basestring): 1122408SN/A self.getCCObject().initMasterName( 1133012Ssaidi@eecs.umich.edu master, float(score)) 1143349Sbinkertn@umich.edu else: 1153012Ssaidi@eecs.umich.edu self.getCCObject().initMasterObj( 1163012Ssaidi@eecs.umich.edu master.getCCObject(), float(score)) 1173012Ssaidi@eecs.umich.edu 1182413SN/A weight = Param.Float(0.5, "Pf score weight") 1193170Sstever@eecs.umich.edu