Sequencer.hh revision 9773
16145Snate@binkert.org/* 26145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 36145Snate@binkert.org * All rights reserved. 46145Snate@binkert.org * 56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 66145Snate@binkert.org * modification, are permitted provided that the following conditions are 76145Snate@binkert.org * met: redistributions of source code must retain the above copyright 86145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 116145Snate@binkert.org * documentation and/or other materials provided with the distribution; 126145Snate@binkert.org * neither the name of the copyright holders nor the names of its 136145Snate@binkert.org * contributors may be used to endorse or promote products derived from 146145Snate@binkert.org * this software without specific prior written permission. 156145Snate@binkert.org * 166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276145Snate@binkert.org */ 286145Snate@binkert.org 297039Snate@binkert.org#ifndef __MEM_RUBY_SYSTEM_SEQUENCER_HH__ 307039Snate@binkert.org#define __MEM_RUBY_SYSTEM_SEQUENCER_HH__ 316145Snate@binkert.org 327055Snate@binkert.org#include <iostream> 337055Snate@binkert.org 347455Snate@binkert.org#include "base/hashmap.hh" 359773Snilay@cs.wisc.edu#include "mem/protocol/MachineType.hh" 368165Snilay@cs.wisc.edu#include "mem/protocol/RubyRequestType.hh" 379104Shestness@cs.utexas.edu#include "mem/protocol/SequencerRequestType.hh" 387039Snate@binkert.org#include "mem/ruby/common/Address.hh" 399171Snilay@cs.wisc.edu#include "mem/ruby/system/CacheMemory.hh" 406285Snate@binkert.org#include "mem/ruby/system/RubyPort.hh" 419171Snilay@cs.wisc.edu#include "params/RubySequencer.hh" 426145Snate@binkert.org 436145Snate@binkert.orgclass DataBlock; 446145Snate@binkert.org 457039Snate@binkert.orgstruct SequencerRequest 467039Snate@binkert.org{ 478615Snilay@cs.wisc.edu PacketPtr pkt; 488615Snilay@cs.wisc.edu RubyRequestType m_type; 499501Snilay@cs.wisc.edu Cycles issue_time; 506285Snate@binkert.org 519501Snilay@cs.wisc.edu SequencerRequest(PacketPtr _pkt, RubyRequestType _m_type, 529501Snilay@cs.wisc.edu Cycles _issue_time) 538615Snilay@cs.wisc.edu : pkt(_pkt), m_type(_m_type), issue_time(_issue_time) 547039Snate@binkert.org {} 556285Snate@binkert.org}; 566285Snate@binkert.org 576763SBrad.Beckmann@amd.comstd::ostream& operator<<(std::ostream& out, const SequencerRequest& obj); 586763SBrad.Beckmann@amd.com 599171Snilay@cs.wisc.educlass Sequencer : public RubyPort 607039Snate@binkert.org{ 617039Snate@binkert.org public: 626876Ssteve.reinhardt@amd.com typedef RubySequencerParams Params; 637039Snate@binkert.org Sequencer(const Params *); 647039Snate@binkert.org ~Sequencer(); 656145Snate@binkert.org 667039Snate@binkert.org // Public Methods 677039Snate@binkert.org void wakeup(); // Used only for deadlock detection 687055Snate@binkert.org void printProgress(std::ostream& out) const; 699598Snilay@cs.wisc.edu void clearStats(); 709598Snilay@cs.wisc.edu 719507Snilay@cs.wisc.edu void writeCallback(const Address& address, 727565SBrad.Beckmann@amd.com DataBlock& data, 739773Snilay@cs.wisc.edu const bool externalHit = false, 749773Snilay@cs.wisc.edu const MachineType mach = MachineType_NUM, 759773Snilay@cs.wisc.edu const Cycles initialRequestTime = Cycles(0), 769773Snilay@cs.wisc.edu const Cycles forwardRequestTime = Cycles(0), 779773Snilay@cs.wisc.edu const Cycles firstResponseTime = Cycles(0)); 786145Snate@binkert.org 799507Snilay@cs.wisc.edu void readCallback(const Address& address, 807565SBrad.Beckmann@amd.com DataBlock& data, 819773Snilay@cs.wisc.edu const bool externalHit = false, 829773Snilay@cs.wisc.edu const MachineType mach = MachineType_NUM, 839773Snilay@cs.wisc.edu const Cycles initialRequestTime = Cycles(0), 849773Snilay@cs.wisc.edu const Cycles forwardRequestTime = Cycles(0), 859773Snilay@cs.wisc.edu const Cycles firstResponseTime = Cycles(0)); 867565SBrad.Beckmann@amd.com 878615Snilay@cs.wisc.edu RequestStatus makeRequest(PacketPtr pkt); 887039Snate@binkert.org bool empty() const; 898688Snilay@cs.wisc.edu int outstandingCount() const { return m_outstanding_count; } 908688Snilay@cs.wisc.edu 919598Snilay@cs.wisc.edu bool isDeadlockEventScheduled() const 929598Snilay@cs.wisc.edu { return deadlockCheckEvent.scheduled(); } 939598Snilay@cs.wisc.edu 949598Snilay@cs.wisc.edu void descheduleDeadlockEvent() 959598Snilay@cs.wisc.edu { deschedule(deadlockCheckEvent); } 966145Snate@binkert.org 977055Snate@binkert.org void print(std::ostream& out) const; 987055Snate@binkert.org void printStats(std::ostream& out) const; 997039Snate@binkert.org void checkCoherence(const Address& address); 1006145Snate@binkert.org 1017455Snate@binkert.org void markRemoved(); 1027039Snate@binkert.org void removeRequest(SequencerRequest* request); 1038717Snilay@cs.wisc.edu void evictionCallback(const Address& address); 1049563Sgope@wisc.edu void invalidateSC(const Address& address); 1056145Snate@binkert.org 1069104Shestness@cs.utexas.edu void recordRequestType(SequencerRequestType requestType); 1079598Snilay@cs.wisc.edu Histogram& getOutstandReqHist() { return m_outstandReqHist; } 1089104Shestness@cs.utexas.edu 1099773Snilay@cs.wisc.edu Histogram& getLatencyHist() { return m_latencyHist; } 1109773Snilay@cs.wisc.edu Histogram& getTypeLatencyHist(uint32_t t) 1119773Snilay@cs.wisc.edu { return m_typeLatencyHist[t]; } 1129773Snilay@cs.wisc.edu 1139773Snilay@cs.wisc.edu Histogram& getHitLatencyHist() { return m_hitLatencyHist; } 1149773Snilay@cs.wisc.edu Histogram& getHitTypeLatencyHist(uint32_t t) 1159773Snilay@cs.wisc.edu { return m_hitTypeLatencyHist[t]; } 1169773Snilay@cs.wisc.edu 1179773Snilay@cs.wisc.edu Histogram& getHitMachLatencyHist(uint32_t t) 1189773Snilay@cs.wisc.edu { return m_hitMachLatencyHist[t]; } 1199773Snilay@cs.wisc.edu 1209773Snilay@cs.wisc.edu Histogram& getHitTypeMachLatencyHist(uint32_t r, uint32_t t) 1219773Snilay@cs.wisc.edu { return m_hitTypeMachLatencyHist[r][t]; } 1229773Snilay@cs.wisc.edu 1239773Snilay@cs.wisc.edu Histogram& getMissLatencyHist() { return m_missLatencyHist; } 1249773Snilay@cs.wisc.edu Histogram& getMissTypeLatencyHist(uint32_t t) 1259773Snilay@cs.wisc.edu { return m_missTypeLatencyHist[t]; } 1269773Snilay@cs.wisc.edu 1279773Snilay@cs.wisc.edu Histogram& getMissMachLatencyHist(uint32_t t) 1289773Snilay@cs.wisc.edu { return m_missMachLatencyHist[t]; } 1299773Snilay@cs.wisc.edu 1309773Snilay@cs.wisc.edu Histogram& getMissTypeMachLatencyHist(uint32_t r, uint32_t t) 1319773Snilay@cs.wisc.edu { return m_missTypeMachLatencyHist[r][t]; } 1329773Snilay@cs.wisc.edu 1339773Snilay@cs.wisc.edu Histogram& getIssueToInitialDelayHist(uint32_t t) 1349773Snilay@cs.wisc.edu { return m_IssueToInitialDelayHist[t]; } 1359773Snilay@cs.wisc.edu 1369773Snilay@cs.wisc.edu Histogram& getInitialToForwardDelayHist(const MachineType t) 1379773Snilay@cs.wisc.edu { return m_InitialToForwardDelayHist[t]; } 1389773Snilay@cs.wisc.edu 1399773Snilay@cs.wisc.edu Histogram& getForwardRequestToFirstResponseHist(const MachineType t) 1409773Snilay@cs.wisc.edu { return m_ForwardToFirstResponseDelayHist[t]; } 1419773Snilay@cs.wisc.edu 1429773Snilay@cs.wisc.edu Histogram& getFirstResponseToCompletionDelayHist(const MachineType t) 1439773Snilay@cs.wisc.edu { return m_FirstResponseToCompletionDelayHist[t]; } 1449773Snilay@cs.wisc.edu 1459773Snilay@cs.wisc.edu const uint64_t getIncompleteTimes(const MachineType t) const 1469773Snilay@cs.wisc.edu { return m_IncompleteTimes[t]; } 1479773Snilay@cs.wisc.edu 1487039Snate@binkert.org private: 1498615Snilay@cs.wisc.edu void issueRequest(PacketPtr pkt, RubyRequestType type); 1506145Snate@binkert.org 1519773Snilay@cs.wisc.edu void hitCallback(SequencerRequest* request, DataBlock& data, 1529773Snilay@cs.wisc.edu bool llscSuccess, 1539773Snilay@cs.wisc.edu const MachineType mach, const bool externalHit, 1549773Snilay@cs.wisc.edu const Cycles initialRequestTime, 1559773Snilay@cs.wisc.edu const Cycles forwardRequestTime, 1569773Snilay@cs.wisc.edu const Cycles firstResponseTime); 1579773Snilay@cs.wisc.edu 1589773Snilay@cs.wisc.edu void recordMissLatency(const Cycles t, const RubyRequestType type, 1599773Snilay@cs.wisc.edu const MachineType respondingMach, 1609773Snilay@cs.wisc.edu bool isExternalHit, Cycles issuedTime, 1619773Snilay@cs.wisc.edu Cycles initialRequestTime, 1629773Snilay@cs.wisc.edu Cycles forwardRequestTime, Cycles firstResponseTime, 1639773Snilay@cs.wisc.edu Cycles completionTime); 1647546SBrad.Beckmann@amd.com 1658615Snilay@cs.wisc.edu RequestStatus insertRequest(PacketPtr pkt, RubyRequestType request_type); 1667560SBrad.Beckmann@amd.com bool handleLlsc(const Address& address, SequencerRequest* request); 1676145Snate@binkert.org 1687039Snate@binkert.org // Private copy constructor and assignment operator 1697039Snate@binkert.org Sequencer(const Sequencer& obj); 1707039Snate@binkert.org Sequencer& operator=(const Sequencer& obj); 1716145Snate@binkert.org 1727039Snate@binkert.org private: 1737039Snate@binkert.org int m_max_outstanding_requests; 1749184Sandreas.hansson@arm.com Cycles m_deadlock_threshold; 1756145Snate@binkert.org 1767039Snate@binkert.org CacheMemory* m_dataCache_ptr; 1777039Snate@binkert.org CacheMemory* m_instCache_ptr; 1786285Snate@binkert.org 1797455Snate@binkert.org typedef m5::hash_map<Address, SequencerRequest*> RequestTable; 1807455Snate@binkert.org RequestTable m_writeRequestTable; 1817455Snate@binkert.org RequestTable m_readRequestTable; 1827039Snate@binkert.org // Global outstanding request count, across all request tables 1837039Snate@binkert.org int m_outstanding_count; 1847039Snate@binkert.org bool m_deadlock_check_scheduled; 1856145Snate@binkert.org 1869507Snilay@cs.wisc.edu uint32_t m_store_waiting_on_load_cycles; 1879507Snilay@cs.wisc.edu uint32_t m_store_waiting_on_store_cycles; 1889507Snilay@cs.wisc.edu uint32_t m_load_waiting_on_store_cycles; 1899507Snilay@cs.wisc.edu uint32_t m_load_waiting_on_load_cycles; 1906859Sdrh5@cs.wisc.edu 1918171Stushar@csail.mit.edu bool m_usingNetworkTester; 1928171Stushar@csail.mit.edu 1939598Snilay@cs.wisc.edu //! Histogram for number of outstanding requests per cycle. 1949598Snilay@cs.wisc.edu Histogram m_outstandReqHist; 1959598Snilay@cs.wisc.edu 1969773Snilay@cs.wisc.edu //! Histogram for holding latency profile of all requests. 1979773Snilay@cs.wisc.edu Histogram m_latencyHist; 1989773Snilay@cs.wisc.edu std::vector<Histogram> m_typeLatencyHist; 1999773Snilay@cs.wisc.edu 2009773Snilay@cs.wisc.edu //! Histogram for holding latency profile of all requests that 2019773Snilay@cs.wisc.edu //! hit in the controller connected to this sequencer. 2029773Snilay@cs.wisc.edu Histogram m_hitLatencyHist; 2039773Snilay@cs.wisc.edu std::vector<Histogram> m_hitTypeLatencyHist; 2049773Snilay@cs.wisc.edu 2059773Snilay@cs.wisc.edu //! Histograms for profiling the latencies for requests that 2069773Snilay@cs.wisc.edu //! did not required external messages. 2079773Snilay@cs.wisc.edu std::vector<Histogram> m_hitMachLatencyHist; 2089773Snilay@cs.wisc.edu std::vector< std::vector<Histogram> > m_hitTypeMachLatencyHist; 2099773Snilay@cs.wisc.edu 2109773Snilay@cs.wisc.edu //! Histogram for holding latency profile of all requests that 2119773Snilay@cs.wisc.edu //! miss in the controller connected to this sequencer. 2129773Snilay@cs.wisc.edu Histogram m_missLatencyHist; 2139773Snilay@cs.wisc.edu std::vector<Histogram> m_missTypeLatencyHist; 2149773Snilay@cs.wisc.edu 2159773Snilay@cs.wisc.edu //! Histograms for profiling the latencies for requests that 2169773Snilay@cs.wisc.edu //! required external messages. 2179773Snilay@cs.wisc.edu std::vector<Histogram> m_missMachLatencyHist; 2189773Snilay@cs.wisc.edu std::vector< std::vector<Histogram> > m_missTypeMachLatencyHist; 2199773Snilay@cs.wisc.edu 2209773Snilay@cs.wisc.edu //! Histograms for recording the breakdown of miss latency 2219773Snilay@cs.wisc.edu std::vector<Histogram> m_IssueToInitialDelayHist; 2229773Snilay@cs.wisc.edu std::vector<Histogram> m_InitialToForwardDelayHist; 2239773Snilay@cs.wisc.edu std::vector<Histogram> m_ForwardToFirstResponseDelayHist; 2249773Snilay@cs.wisc.edu std::vector<Histogram> m_FirstResponseToCompletionDelayHist; 2259773Snilay@cs.wisc.edu std::vector<uint64_t> m_IncompleteTimes; 2269773Snilay@cs.wisc.edu 2279773Snilay@cs.wisc.edu 2287039Snate@binkert.org class SequencerWakeupEvent : public Event 2297039Snate@binkert.org { 2307039Snate@binkert.org private: 2317039Snate@binkert.org Sequencer *m_sequencer_ptr; 2326899SBrad.Beckmann@amd.com 2337039Snate@binkert.org public: 2347039Snate@binkert.org SequencerWakeupEvent(Sequencer *_seq) : m_sequencer_ptr(_seq) {} 2357039Snate@binkert.org void process() { m_sequencer_ptr->wakeup(); } 2367039Snate@binkert.org const char *description() const { return "Sequencer deadlock check"; } 2377039Snate@binkert.org }; 2386886SBrad.Beckmann@amd.com 2397039Snate@binkert.org SequencerWakeupEvent deadlockCheckEvent; 2406145Snate@binkert.org}; 2416145Snate@binkert.org 2427055Snate@binkert.orginline std::ostream& 2437055Snate@binkert.orgoperator<<(std::ostream& out, const Sequencer& obj) 2446145Snate@binkert.org{ 2457039Snate@binkert.org obj.print(out); 2467055Snate@binkert.org out << std::flush; 2477039Snate@binkert.org return out; 2486145Snate@binkert.org} 2496145Snate@binkert.org 2507039Snate@binkert.org#endif // __MEM_RUBY_SYSTEM_SEQUENCER_HH__ 251