Sequencer.hh revision 9598
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" 358229Snate@binkert.org#include "mem/protocol/GenericMachineType.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 686145Snate@binkert.org 697055Snate@binkert.org void printProgress(std::ostream& out) const; 706145Snate@binkert.org 719598Snilay@cs.wisc.edu void clearStats(); 729598Snilay@cs.wisc.edu 737039Snate@binkert.org void writeCallback(const Address& address, DataBlock& data); 747546SBrad.Beckmann@amd.com 759507Snilay@cs.wisc.edu void writeCallback(const Address& address, 769507Snilay@cs.wisc.edu GenericMachineType mach, 777546SBrad.Beckmann@amd.com DataBlock& data); 787546SBrad.Beckmann@amd.com 799507Snilay@cs.wisc.edu void writeCallback(const Address& address, 809507Snilay@cs.wisc.edu GenericMachineType mach, 817565SBrad.Beckmann@amd.com DataBlock& data, 829507Snilay@cs.wisc.edu Cycles initialRequestTime, 839507Snilay@cs.wisc.edu Cycles forwardRequestTime, 849507Snilay@cs.wisc.edu Cycles firstResponseTime); 857565SBrad.Beckmann@amd.com 867039Snate@binkert.org void readCallback(const Address& address, DataBlock& data); 876145Snate@binkert.org 889507Snilay@cs.wisc.edu void readCallback(const Address& address, 899507Snilay@cs.wisc.edu GenericMachineType mach, 907546SBrad.Beckmann@amd.com DataBlock& data); 917546SBrad.Beckmann@amd.com 929507Snilay@cs.wisc.edu void readCallback(const Address& address, 939507Snilay@cs.wisc.edu GenericMachineType mach, 947565SBrad.Beckmann@amd.com DataBlock& data, 959507Snilay@cs.wisc.edu Cycles initialRequestTime, 969507Snilay@cs.wisc.edu Cycles forwardRequestTime, 979507Snilay@cs.wisc.edu Cycles firstResponseTime); 987565SBrad.Beckmann@amd.com 998615Snilay@cs.wisc.edu RequestStatus makeRequest(PacketPtr pkt); 1007039Snate@binkert.org bool empty() const; 1018688Snilay@cs.wisc.edu int outstandingCount() const { return m_outstanding_count; } 1028688Snilay@cs.wisc.edu 1039598Snilay@cs.wisc.edu bool isDeadlockEventScheduled() const 1049598Snilay@cs.wisc.edu { return deadlockCheckEvent.scheduled(); } 1059598Snilay@cs.wisc.edu 1069598Snilay@cs.wisc.edu void descheduleDeadlockEvent() 1079598Snilay@cs.wisc.edu { deschedule(deadlockCheckEvent); } 1086145Snate@binkert.org 1097055Snate@binkert.org void print(std::ostream& out) const; 1107055Snate@binkert.org void printStats(std::ostream& out) const; 1117039Snate@binkert.org void checkCoherence(const Address& address); 1126145Snate@binkert.org 1137455Snate@binkert.org void markRemoved(); 1147039Snate@binkert.org void removeRequest(SequencerRequest* request); 1158717Snilay@cs.wisc.edu void evictionCallback(const Address& address); 1169563Sgope@wisc.edu void invalidateSC(const Address& address); 1176145Snate@binkert.org 1189104Shestness@cs.utexas.edu void recordRequestType(SequencerRequestType requestType); 1199598Snilay@cs.wisc.edu Histogram& getOutstandReqHist() { return m_outstandReqHist; } 1209104Shestness@cs.utexas.edu 1217039Snate@binkert.org private: 1228615Snilay@cs.wisc.edu void issueRequest(PacketPtr pkt, RubyRequestType type); 1236145Snate@binkert.org 1249507Snilay@cs.wisc.edu void hitCallback(SequencerRequest* request, 1257546SBrad.Beckmann@amd.com GenericMachineType mach, 1267560SBrad.Beckmann@amd.com DataBlock& data, 1277565SBrad.Beckmann@amd.com bool success, 1289507Snilay@cs.wisc.edu Cycles initialRequestTime, 1299507Snilay@cs.wisc.edu Cycles forwardRequestTime, 1309507Snilay@cs.wisc.edu Cycles firstResponseTime); 1317546SBrad.Beckmann@amd.com 1328615Snilay@cs.wisc.edu RequestStatus insertRequest(PacketPtr pkt, RubyRequestType request_type); 1336285Snate@binkert.org 1347560SBrad.Beckmann@amd.com bool handleLlsc(const Address& address, SequencerRequest* request); 1356145Snate@binkert.org 1367039Snate@binkert.org // Private copy constructor and assignment operator 1377039Snate@binkert.org Sequencer(const Sequencer& obj); 1387039Snate@binkert.org Sequencer& operator=(const Sequencer& obj); 1396145Snate@binkert.org 1407039Snate@binkert.org private: 1417039Snate@binkert.org int m_max_outstanding_requests; 1429184Sandreas.hansson@arm.com Cycles m_deadlock_threshold; 1436145Snate@binkert.org 1447039Snate@binkert.org CacheMemory* m_dataCache_ptr; 1457039Snate@binkert.org CacheMemory* m_instCache_ptr; 1466285Snate@binkert.org 1477455Snate@binkert.org typedef m5::hash_map<Address, SequencerRequest*> RequestTable; 1487455Snate@binkert.org RequestTable m_writeRequestTable; 1497455Snate@binkert.org RequestTable m_readRequestTable; 1507039Snate@binkert.org // Global outstanding request count, across all request tables 1517039Snate@binkert.org int m_outstanding_count; 1527039Snate@binkert.org bool m_deadlock_check_scheduled; 1536145Snate@binkert.org 1549507Snilay@cs.wisc.edu uint32_t m_store_waiting_on_load_cycles; 1559507Snilay@cs.wisc.edu uint32_t m_store_waiting_on_store_cycles; 1569507Snilay@cs.wisc.edu uint32_t m_load_waiting_on_store_cycles; 1579507Snilay@cs.wisc.edu uint32_t m_load_waiting_on_load_cycles; 1586859Sdrh5@cs.wisc.edu 1598171Stushar@csail.mit.edu bool m_usingNetworkTester; 1608171Stushar@csail.mit.edu 1619598Snilay@cs.wisc.edu //! Histogram for number of outstanding requests per cycle. 1629598Snilay@cs.wisc.edu Histogram m_outstandReqHist; 1639598Snilay@cs.wisc.edu 1647039Snate@binkert.org class SequencerWakeupEvent : public Event 1657039Snate@binkert.org { 1667039Snate@binkert.org private: 1677039Snate@binkert.org Sequencer *m_sequencer_ptr; 1686899SBrad.Beckmann@amd.com 1697039Snate@binkert.org public: 1707039Snate@binkert.org SequencerWakeupEvent(Sequencer *_seq) : m_sequencer_ptr(_seq) {} 1717039Snate@binkert.org void process() { m_sequencer_ptr->wakeup(); } 1727039Snate@binkert.org const char *description() const { return "Sequencer deadlock check"; } 1737039Snate@binkert.org }; 1746886SBrad.Beckmann@amd.com 1757039Snate@binkert.org SequencerWakeupEvent deadlockCheckEvent; 1766145Snate@binkert.org}; 1776145Snate@binkert.org 1787055Snate@binkert.orginline std::ostream& 1797055Snate@binkert.orgoperator<<(std::ostream& out, const Sequencer& obj) 1806145Snate@binkert.org{ 1817039Snate@binkert.org obj.print(out); 1827055Snate@binkert.org out << std::flush; 1837039Snate@binkert.org return out; 1846145Snate@binkert.org} 1856145Snate@binkert.org 1867039Snate@binkert.org#endif // __MEM_RUBY_SYSTEM_SEQUENCER_HH__ 187