AbstractController.hh revision 9595
17008Snate@binkert.org/* 27008Snate@binkert.org * Copyright (c) 2009 Mark D. Hill and David A. Wood 37008Snate@binkert.org * All rights reserved. 47008Snate@binkert.org * 57008Snate@binkert.org * Redistribution and use in source and binary forms, with or without 67008Snate@binkert.org * modification, are permitted provided that the following conditions are 77008Snate@binkert.org * met: redistributions of source code must retain the above copyright 87008Snate@binkert.org * notice, this list of conditions and the following disclaimer; 97008Snate@binkert.org * redistributions in binary form must reproduce the above copyright 107008Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 117008Snate@binkert.org * documentation and/or other materials provided with the distribution; 127008Snate@binkert.org * neither the name of the copyright holders nor the names of its 137008Snate@binkert.org * contributors may be used to endorse or promote products derived from 147008Snate@binkert.org * this software without specific prior written permission. 157008Snate@binkert.org * 167008Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 177008Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 187008Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 197008Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 207008Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 217008Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 227008Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 237008Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 247008Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 257008Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 267008Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 277008Snate@binkert.org */ 286285Snate@binkert.org 297039Snate@binkert.org#ifndef __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCONTROLLER_HH__ 307039Snate@binkert.org#define __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCONTROLLER_HH__ 316285Snate@binkert.org 327055Snate@binkert.org#include <iostream> 337055Snate@binkert.org#include <string> 346876Ssteve.reinhardt@amd.com 358341Snilay@cs.wisc.edu#include "mem/protocol/AccessPermission.hh" 366506Spdudnik@gmail.com#include "mem/ruby/common/Address.hh" 377055Snate@binkert.org#include "mem/ruby/common/Consumer.hh" 388436SBrad.Beckmann@amd.com#include "mem/ruby/common/DataBlock.hh" 399497Snilay@cs.wisc.edu#include "mem/ruby/common/Histogram.hh" 406881SBrad.Beckmann@amd.com#include "mem/ruby/network/Network.hh" 418683Snilay@cs.wisc.edu#include "mem/ruby/recorder/CacheRecorder.hh" 429364Snilay@cs.wisc.edu#include "mem/ruby/system/MachineID.hh" 439364Snilay@cs.wisc.edu#include "mem/packet.hh" 447055Snate@binkert.org#include "params/RubyController.hh" 459465Snilay@cs.wisc.edu#include "sim/clocked_object.hh" 466285Snate@binkert.org 476285Snate@binkert.orgclass MessageBuffer; 486285Snate@binkert.orgclass Network; 496285Snate@binkert.org 509465Snilay@cs.wisc.educlass AbstractController : public ClockedObject, public Consumer 517039Snate@binkert.org{ 527039Snate@binkert.org public: 536876Ssteve.reinhardt@amd.com typedef RubyControllerParams Params; 548436SBrad.Beckmann@amd.com AbstractController(const Params *p); 559496Snilay@cs.wisc.edu void init(); 568257SBrad.Beckmann@amd.com const Params *params() const { return (const Params *)_params; } 577039Snate@binkert.org virtual MessageBuffer* getMandatoryQueue() const = 0; 587039Snate@binkert.org virtual const int & getVersion() const = 0; 597055Snate@binkert.org virtual const std::string toString() const = 0; // returns text version of 607055Snate@binkert.org // controller type 617055Snate@binkert.org virtual const std::string getName() const = 0; // return instance name 627039Snate@binkert.org virtual void blockOnQueue(Address, MessageBuffer*) = 0; 637039Snate@binkert.org virtual void unblock(Address) = 0; 647039Snate@binkert.org virtual void initNetworkPtr(Network* net_ptr) = 0; 658531Snilay@cs.wisc.edu virtual AccessPermission getAccessPermission(const Address& addr) = 0; 668531Snilay@cs.wisc.edu virtual DataBlock& getDataBlock(const Address& addr) = 0; 676285Snate@binkert.org 687055Snate@binkert.org virtual void print(std::ostream & out) const = 0; 697055Snate@binkert.org virtual void printStats(std::ostream & out) const = 0; 707039Snate@binkert.org virtual void wakeup() = 0; 717055Snate@binkert.org // virtual void dumpStats(std::ostream & out) = 0; 727039Snate@binkert.org virtual void clearStats() = 0; 738683Snilay@cs.wisc.edu virtual void recordCacheTrace(int cntrl, CacheRecorder* tr) = 0; 748683Snilay@cs.wisc.edu virtual Sequencer* getSequencer() const = 0; 759302Snilay@cs.wisc.edu 769302Snilay@cs.wisc.edu //! These functions are used by ruby system to read/write the message 779302Snilay@cs.wisc.edu //! queues that exist with in the controller. 789302Snilay@cs.wisc.edu //! The boolean return value indicates if the read was performed 799302Snilay@cs.wisc.edu //! successfully. 809302Snilay@cs.wisc.edu virtual bool functionalReadBuffers(PacketPtr&) = 0; 819302Snilay@cs.wisc.edu //! The return value indicates the number of messages written with the 829302Snilay@cs.wisc.edu //! data from the packet. 839302Snilay@cs.wisc.edu virtual uint32_t functionalWriteBuffers(PacketPtr&) = 0; 849363Snilay@cs.wisc.edu 859363Snilay@cs.wisc.edu //! Function for enqueuing a prefetch request 869363Snilay@cs.wisc.edu virtual void enqueuePrefetch(const Address&, const RubyRequestType&) 879363Snilay@cs.wisc.edu { fatal("Prefetches not implemented!");} 889364Snilay@cs.wisc.edu 899496Snilay@cs.wisc.edu public: 909496Snilay@cs.wisc.edu MachineID getMachineID() const { return m_machineID; } 919496Snilay@cs.wisc.edu uint64_t getFullyBusyCycles() const { return m_fully_busy_cycles; } 929496Snilay@cs.wisc.edu uint64_t getRequestCount() const { return m_request_count; } 939496Snilay@cs.wisc.edu const std::map<std::string, uint64_t>& getRequestProfileMap() const 949496Snilay@cs.wisc.edu { return m_requestProfileMap; } 959496Snilay@cs.wisc.edu 969497Snilay@cs.wisc.edu Histogram& getDelayHist() { return m_delayHistogram; } 979497Snilay@cs.wisc.edu Histogram& getDelayVCHist(uint32_t index) 989497Snilay@cs.wisc.edu { return m_delayVCHistogram[index]; } 999497Snilay@cs.wisc.edu 1009595Snilay@cs.wisc.edu MessageBuffer *getPeerQueue(uint32_t pid) 1019595Snilay@cs.wisc.edu { 1029595Snilay@cs.wisc.edu std::map<uint32_t, MessageBuffer *>::iterator it = 1039595Snilay@cs.wisc.edu peerQueueMap.find(pid); 1049595Snilay@cs.wisc.edu assert(it != peerQueueMap.end()); 1059595Snilay@cs.wisc.edu return (*it).second; 1069595Snilay@cs.wisc.edu } 1079595Snilay@cs.wisc.edu 1089496Snilay@cs.wisc.edu protected: 1099496Snilay@cs.wisc.edu //! Profiles original cache requests including PUTs 1109496Snilay@cs.wisc.edu void profileRequest(const std::string &request); 1119497Snilay@cs.wisc.edu //! Profiles the delay associated with messages. 1129507Snilay@cs.wisc.edu void profileMsgDelay(uint32_t virtualNetwork, Cycles delay); 1139496Snilay@cs.wisc.edu 1149595Snilay@cs.wisc.edu //! Function for connecting peer controllers 1159595Snilay@cs.wisc.edu void connectWithPeer(AbstractController *); 1169595Snilay@cs.wisc.edu virtual void getQueuesFromPeer(AbstractController *) 1179595Snilay@cs.wisc.edu { fatal("getQueuesFromPeer() should be called only if implemented!"); } 1189595Snilay@cs.wisc.edu 1199364Snilay@cs.wisc.edu protected: 1209364Snilay@cs.wisc.edu int m_transitions_per_cycle; 1219364Snilay@cs.wisc.edu int m_buffer_size; 1229499Snilay@cs.wisc.edu Cycles m_recycle_latency; 1239364Snilay@cs.wisc.edu std::string m_name; 1249364Snilay@cs.wisc.edu NodeID m_version; 1259364Snilay@cs.wisc.edu Network* m_net_ptr; 1269364Snilay@cs.wisc.edu MachineID m_machineID; 1279364Snilay@cs.wisc.edu bool m_is_blocking; 1289364Snilay@cs.wisc.edu std::map<Address, MessageBuffer*> m_block_map; 1299364Snilay@cs.wisc.edu typedef std::vector<MessageBuffer*> MsgVecType; 1309364Snilay@cs.wisc.edu typedef std::map< Address, MsgVecType* > WaitingBufType; 1319364Snilay@cs.wisc.edu WaitingBufType m_waiting_buffers; 1329364Snilay@cs.wisc.edu int m_max_in_port_rank; 1339364Snilay@cs.wisc.edu int m_cur_in_port_rank; 1349364Snilay@cs.wisc.edu int m_number_of_TBEs; 1359496Snilay@cs.wisc.edu 1369595Snilay@cs.wisc.edu //! Map from physical network number to the Message Buffer. 1379595Snilay@cs.wisc.edu std::map<uint32_t, MessageBuffer*> peerQueueMap; 1389595Snilay@cs.wisc.edu 1399496Snilay@cs.wisc.edu //! Counter for the number of cycles when the transitions carried out 1409496Snilay@cs.wisc.edu //! were equal to the maximum allowed 1419496Snilay@cs.wisc.edu uint64_t m_fully_busy_cycles; 1429496Snilay@cs.wisc.edu 1439496Snilay@cs.wisc.edu //! Map for couting requests of different types. The controller should 1449496Snilay@cs.wisc.edu //! call requisite function for updating the count. 1459496Snilay@cs.wisc.edu std::map<std::string, uint64_t> m_requestProfileMap; 1469496Snilay@cs.wisc.edu uint64_t m_request_count; 1479497Snilay@cs.wisc.edu 1489497Snilay@cs.wisc.edu //! Histogram for profiling delay for the messages this controller 1499497Snilay@cs.wisc.edu //! cares for 1509497Snilay@cs.wisc.edu Histogram m_delayHistogram; 1519497Snilay@cs.wisc.edu std::vector<Histogram> m_delayVCHistogram; 1526285Snate@binkert.org}; 1536285Snate@binkert.org 1547039Snate@binkert.org#endif // __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCONTROLLER_HH__ 155