From 5187a24d496cd16bfe440f52ff0c45ab0e185306 Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Wed, 4 Apr 2018 16:27:04 +0100 Subject: sim,cpu,mem,arch: Introduced MasterInfo data structure With this patch a gem5 System will store more info about its Masters. While it was previously keeping track of the Master name and Master ID only, it is now adding a per-Master pointer to the SimObject related to the Master. This will make it possible for a client to query a System for a Master using either the master's name or the master's pointer. Change-Id: I8b97d328a65cd06f329e2cdd3679451c17d2b8f6 Signed-off-by: Giacomo Travaglini Reviewed-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/9781 Reviewed-by: Jason Lowe-Power Maintainer: Nikos Nikoleris --- src/sim/system.hh | 67 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 10 deletions(-) (limited to 'src/sim/system.hh') diff --git a/src/sim/system.hh b/src/sim/system.hh index a72f2a762..0d26ffa0d 100644 --- a/src/sim/system.hh +++ b/src/sim/system.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014 ARM Limited + * Copyright (c) 2012, 2014, 2018 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -57,6 +57,7 @@ #include "base/statistics.hh" #include "config/the_isa.hh" #include "enums/MemoryMode.hh" +#include "mem/mem_master.hh" #include "mem/mem_object.hh" #include "mem/physical.hh" #include "mem/port.hh" @@ -320,31 +321,77 @@ class System : public MemObject * It's used to uniquely id any master in the system by name for things * like cache statistics. */ - std::vector masterIds; + std::vector masters; ThermalModel * thermalModel; public: - /** Request an id used to create a request object in the system. All objects + /** + * Request an id used to create a request object in the system. All objects * that intend to issues requests into the memory system must request an id * in the init() phase of startup. All master ids must be fixed by the * regStats() phase that immediately precedes it. This allows objects in * the memory system to understand how many masters may exist and * appropriately name the bins of their per-master stats before the stats - * are finalized + * are finalized. + * + * Registers a MasterID: + * This method takes two parameters, one of which is optional. + * The first one is the master object, and it is compulsory; in case + * a object has multiple (sub)masters, a second parameter must be + * provided and it contains the name of the submaster. The method will + * create a master's name by concatenating the SimObject name with the + * eventual submaster string, separated by a dot. + * + * As an example: + * For a cpu having two masters: a data master and an instruction master, + * the method must be called twice: + * + * instMasterId = getMasterId(cpu, "inst"); + * dataMasterId = getMasterId(cpu, "data"); + * + * and the masters' names will be: + * - "cpu.inst" + * - "cpu.data" + * + * @param master SimObject related to the master + * @param submaster String containing the submaster's name + * @return the master's ID. + */ + MasterID getMasterId(const SimObject* master, + std::string submaster = std::string()); + + /** + * Registers a GLOBAL MasterID, which is a MasterID not related + * to any particular SimObject; since no SimObject is passed, + * the master gets registered by providing the full master name. + * + * @param masterName full name of the master + * @return the master's ID. */ - MasterID getMasterId(std::string req_name); + MasterID getGlobalMasterId(std::string master_name); - /** Get the name of an object for a given request id. + /** + * Get the name of an object for a given request id. */ std::string getMasterName(MasterID master_id); /** Get the number of masters registered in the system */ - MasterID maxMasters() - { - return masterIds.size(); - } + MasterID maxMasters() { return masters.size(); } + + protected: + /** helper function for getMasterId */ + MasterID _getMasterId(const SimObject* master, std::string master_name); + + /** + * Helper function for constructing the full (sub)master name + * by providing the root master and the relative submaster name. + */ + std::string leafMasterName(const SimObject* master, + const std::string& submaster); + + public: void regStats() override; /** -- cgit v1.2.3