RubySystem.hh revision 10918
19651SAndreas.Sandberg@ARM.com/* 29651SAndreas.Sandberg@ARM.com * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 39651SAndreas.Sandberg@ARM.com * All rights reserved. 49651SAndreas.Sandberg@ARM.com * 59651SAndreas.Sandberg@ARM.com * Redistribution and use in source and binary forms, with or without 69651SAndreas.Sandberg@ARM.com * modification, are permitted provided that the following conditions are 79651SAndreas.Sandberg@ARM.com * met: redistributions of source code must retain the above copyright 89651SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer; 99651SAndreas.Sandberg@ARM.com * redistributions in binary form must reproduce the above copyright 109651SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer in the 119651SAndreas.Sandberg@ARM.com * documentation and/or other materials provided with the distribution; 129651SAndreas.Sandberg@ARM.com * neither the name of the copyright holders nor the names of its 139651SAndreas.Sandberg@ARM.com * contributors may be used to endorse or promote products derived from 149651SAndreas.Sandberg@ARM.com * this software without specific prior written permission. 159651SAndreas.Sandberg@ARM.com * 169651SAndreas.Sandberg@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179651SAndreas.Sandberg@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189651SAndreas.Sandberg@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 199651SAndreas.Sandberg@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 209651SAndreas.Sandberg@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219651SAndreas.Sandberg@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 229651SAndreas.Sandberg@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 239651SAndreas.Sandberg@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 249651SAndreas.Sandberg@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 259651SAndreas.Sandberg@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 269651SAndreas.Sandberg@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 279651SAndreas.Sandberg@ARM.com */ 289651SAndreas.Sandberg@ARM.com 299651SAndreas.Sandberg@ARM.com/* 309651SAndreas.Sandberg@ARM.com * Contains all of the various parts of the system we are simulating. 319651SAndreas.Sandberg@ARM.com * Performs allocation, deallocation, and setup of all the major 329651SAndreas.Sandberg@ARM.com * components of the system 339651SAndreas.Sandberg@ARM.com */ 349651SAndreas.Sandberg@ARM.com 359651SAndreas.Sandberg@ARM.com#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__ 369651SAndreas.Sandberg@ARM.com#define __MEM_RUBY_SYSTEM_SYSTEM_HH__ 379651SAndreas.Sandberg@ARM.com 389651SAndreas.Sandberg@ARM.com#include "base/callback.hh" 399651SAndreas.Sandberg@ARM.com#include "base/output.hh" 409651SAndreas.Sandberg@ARM.com#include "mem/ruby/profiler/Profiler.hh" 419651SAndreas.Sandberg@ARM.com#include "mem/ruby/slicc_interface/AbstractController.hh" 429651SAndreas.Sandberg@ARM.com#include "mem/ruby/system/CacheRecorder.hh" 439651SAndreas.Sandberg@ARM.com#include "mem/packet.hh" 449651SAndreas.Sandberg@ARM.com#include "params/RubySystem.hh" 459651SAndreas.Sandberg@ARM.com#include "sim/clocked_object.hh" 469651SAndreas.Sandberg@ARM.com 4710859Sandreas.sandberg@arm.comclass Network; 489651SAndreas.Sandberg@ARM.com 499651SAndreas.Sandberg@ARM.comclass RubySystem : public ClockedObject 509651SAndreas.Sandberg@ARM.com{ 519651SAndreas.Sandberg@ARM.com public: 5210857Sandreas.sandberg@arm.com class RubyEvent : public Event 539883Sandreas@sandberg.pp.se { 549883Sandreas@sandberg.pp.se public: 559657Sandreas.sandberg@arm.com RubyEvent(RubySystem* _ruby_system) 569651SAndreas.Sandberg@ARM.com { 579651SAndreas.Sandberg@ARM.com ruby_system = _ruby_system; 589651SAndreas.Sandberg@ARM.com } 599651SAndreas.Sandberg@ARM.com private: 609651SAndreas.Sandberg@ARM.com void process(); 619651SAndreas.Sandberg@ARM.com 629651SAndreas.Sandberg@ARM.com RubySystem* ruby_system; 639651SAndreas.Sandberg@ARM.com }; 649651SAndreas.Sandberg@ARM.com 659651SAndreas.Sandberg@ARM.com friend class RubyEvent; 66 67 typedef RubySystemParams Params; 68 RubySystem(const Params *p); 69 ~RubySystem(); 70 71 // config accessors 72 static int getRandomSeed() { return m_random_seed; } 73 static int getRandomization() { return m_randomization; } 74 static uint32_t getBlockSizeBytes() { return m_block_size_bytes; } 75 static uint32_t getBlockSizeBits() { return m_block_size_bits; } 76 static uint32_t getMemorySizeBits() { return m_memory_size_bits; } 77 static bool getWarmupEnabled() { return m_warmup_enabled; } 78 static bool getCooldownEnabled() { return m_cooldown_enabled; } 79 80 SimpleMemory *getPhysMem() { return m_phys_mem; } 81 Cycles getStartCycle() { return m_start_cycle; } 82 const bool getAccessBackingStore() { return m_access_backing_store; } 83 84 // Public Methods 85 Profiler* 86 getProfiler() 87 { 88 assert(m_profiler != NULL); 89 return m_profiler; 90 } 91 92 void regStats() { m_profiler->regStats(name()); } 93 void collateStats() { m_profiler->collateStats(); } 94 void resetStats(); 95 96 void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE; 97 void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; 98 void process(); 99 void startup(); 100 bool functionalRead(Packet *ptr); 101 bool functionalWrite(Packet *ptr); 102 103 void registerNetwork(Network*); 104 void registerAbstractController(AbstractController*); 105 106 bool eventQueueEmpty() { return eventq->empty(); } 107 void enqueueRubyEvent(Tick tick) 108 { 109 RubyEvent* e = new RubyEvent(this); 110 schedule(e, tick); 111 } 112 113 private: 114 // Private copy constructor and assignment operator 115 RubySystem(const RubySystem& obj); 116 RubySystem& operator=(const RubySystem& obj); 117 118 void readCompressedTrace(std::string filename, 119 uint8_t *&raw_data, 120 uint64& uncompressed_trace_size); 121 void writeCompressedTrace(uint8_t *raw_data, std::string file, 122 uint64 uncompressed_trace_size); 123 124 private: 125 // configuration parameters 126 static int m_random_seed; 127 static bool m_randomization; 128 static uint32_t m_block_size_bytes; 129 static uint32_t m_block_size_bits; 130 static uint32_t m_memory_size_bits; 131 static bool m_warmup_enabled; 132 static unsigned m_systems_to_warmup; 133 static bool m_cooldown_enabled; 134 SimpleMemory *m_phys_mem; 135 const bool m_access_backing_store; 136 137 Network* m_network; 138 std::vector<AbstractController *> m_abs_cntrl_vec; 139 Cycles m_start_cycle; 140 141 public: 142 Profiler* m_profiler; 143 CacheRecorder* m_cache_recorder; 144}; 145 146class RubyStatsCallback : public Callback 147{ 148 private: 149 RubySystem *ruby_system; 150 151 public: 152 virtual ~RubyStatsCallback() {} 153 RubyStatsCallback(RubySystem *system) : ruby_system(system) {} 154 void process() { ruby_system->collateStats(); } 155}; 156 157#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ 158