RubySystem.hh revision 7562
1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/* 30 * Contains all of the various parts of the system we are simulating. 31 * Performs allocation, deallocation, and setup of all the major 32 * components of the system 33 */ 34 35#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__ 36#define __MEM_RUBY_SYSTEM_SYSTEM_HH__ 37 38#include "base/callback.hh" 39#include "mem/ruby/common/Global.hh" 40#include "mem/ruby/eventqueue/RubyEventQueue.hh" 41#include "mem/ruby/system/RubyPort.hh" 42#include "params/RubySystem.hh" 43#include "sim/sim_object.hh" 44 45class CacheRecorder; 46class MemoryVector; 47class Network; 48class Profiler; 49class Tracer; 50 51/* 52 * This defines the number of longs (32-bits on 32 bit machines, 53 * 64-bit on 64-bit AMD machines) to use to hold the set... 54 * the default is 4, allowing 128 or 256 different members 55 * of the set. 56 * 57 * This should never need to be changed for correctness reasons, 58 * though increasing it will increase performance for larger 59 * set sizes at the cost of a (much) larger memory footprint 60 * 61 */ 62const int NUMBER_WORDS_PER_SET = 1; 63 64class RubySystem : public SimObject 65{ 66 public: 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 int getBlockSizeBytes() { return m_block_size_bytes; } 75 static int getBlockSizeBits() { return m_block_size_bits; } 76 static uint64 getMemorySizeBytes() { return m_memory_size_bytes; } 77 static int getMemorySizeBits() { return m_memory_size_bits; } 78 79 // Public Methods 80 static Network* 81 getNetwork() 82 { 83 assert(m_network_ptr != NULL); 84 return m_network_ptr; 85 } 86 87 static RubyEventQueue* 88 getEventQueue() 89 { 90 return g_eventQueue_ptr; 91 } 92 93 Profiler* 94 getProfiler() 95 { 96 assert(m_profiler_ptr != NULL); 97 return m_profiler_ptr; 98 } 99 100 static Tracer* 101 getTracer() 102 { 103 assert(m_tracer_ptr != NULL); 104 return m_tracer_ptr; 105 } 106 107 static MemoryVector* 108 getMemoryVector() 109 { 110 assert(m_mem_vec_ptr != NULL); 111 return m_mem_vec_ptr; 112 } 113 114 void recordCacheContents(CacheRecorder& tr) const; 115 static void printConfig(std::ostream& out); 116 static void printStats(std::ostream& out); 117 void clearStats() const; 118 119 uint64 getInstructionCount(int thread) { return 1; } 120 static uint64 121 getCycleCount(int thread) 122 { 123 return g_eventQueue_ptr->getTime(); 124 } 125 126 void print(std::ostream& out) const; 127 128 virtual void serialize(std::ostream &os); 129 virtual void unserialize(Checkpoint *cp, const std::string §ion); 130 131 private: 132 // Private copy constructor and assignment operator 133 RubySystem(const RubySystem& obj); 134 RubySystem& operator=(const RubySystem& obj); 135 136 void init(); 137 138 static void printSystemConfig(std::ostream& out); 139 140 private: 141 // configuration parameters 142 static int m_random_seed; 143 static bool m_randomization; 144 static Tick m_clock; 145 static int m_block_size_bytes; 146 static int m_block_size_bits; 147 static uint64 m_memory_size_bytes; 148 static int m_memory_size_bits; 149 150 static Network* m_network_ptr; 151 152 public: 153 static Profiler* m_profiler_ptr; 154 static Tracer* m_tracer_ptr; 155 static MemoryVector* m_mem_vec_ptr; 156}; 157 158inline std::ostream& 159operator<<(std::ostream& out, const RubySystem& obj) 160{ 161 //obj.print(out); 162 out << std::flush; 163 return out; 164} 165 166class RubyExitCallback : public Callback 167{ 168 private: 169 std::string stats_filename; 170 171 public: 172 virtual ~RubyExitCallback() {} 173 174 RubyExitCallback(const std::string& _stats_filename) 175 { 176 stats_filename = _stats_filename; 177 } 178 179 virtual void process(); 180}; 181 182#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ 183 184 185 186