RubySystem.hh revision 7039
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/gems_common/Vector.hh" 40#include "mem/ruby/common/Global.hh" 41#include "mem/ruby/eventqueue/RubyEventQueue.hh" 42#include "mem/ruby/system/RubyPort.hh" 43#include "params/RubySystem.hh" 44#include "sim/sim_object.hh" 45 46class CacheRecorder; 47class MemoryVector; 48class Network; 49class Profiler; 50class Tracer; 51 52/* 53 * This defines the number of longs (32-bits on 32 bit machines, 54 * 64-bit on 64-bit AMD machines) to use to hold the set... 55 * the default is 4, allowing 128 or 256 different members 56 * of the set. 57 * 58 * This should never need to be changed for correctness reasons, 59 * though increasing it will increase performance for larger 60 * set sizes at the cost of a (much) larger memory footprint 61 * 62 */ 63const int NUMBER_WORDS_PER_SET = 1; 64 65class RubySystem : public SimObject 66{ 67 public: 68 typedef RubySystemParams Params; 69 RubySystem(const Params *p); 70 ~RubySystem(); 71 72 // config accessors 73 static int getRandomSeed() { return m_random_seed; } 74 static int getRandomization() { return m_randomization; } 75 static int getBlockSizeBytes() { return m_block_size_bytes; } 76 static int getBlockSizeBits() { return m_block_size_bits; } 77 static uint64 getMemorySizeBytes() { return m_memory_size_bytes; } 78 static int getMemorySizeBits() { return m_memory_size_bits; } 79 80 // Public Methods 81 static Network* 82 getNetwork() 83 { 84 assert(m_network_ptr != NULL); 85 return m_network_ptr; 86 } 87 88 static RubyEventQueue* 89 getEventQueue() 90 { 91 return g_eventQueue_ptr; 92 } 93 94 Profiler* 95 getProfiler() 96 { 97 assert(m_profiler_ptr != NULL); 98 return m_profiler_ptr; 99 } 100 101 static Tracer* 102 getTracer() 103 { 104 assert(m_tracer_ptr != NULL); 105 return m_tracer_ptr; 106 } 107 108 static MemoryVector* 109 getMemoryVector() 110 { 111 assert(m_mem_vec_ptr != NULL); 112 return m_mem_vec_ptr; 113 } 114 115 void recordCacheContents(CacheRecorder& tr) const; 116 static void printConfig(ostream& out); 117 static void printStats(ostream& out); 118 void clearStats() const; 119 120 uint64 getInstructionCount(int thread) { return 1; } 121 static uint64 122 getCycleCount(int thread) 123 { 124 return g_eventQueue_ptr->getTime(); 125 } 126 127 void print(ostream& out) const; 128 129 private: 130 // Private copy constructor and assignment operator 131 RubySystem(const RubySystem& obj); 132 RubySystem& operator=(const RubySystem& obj); 133 134 void init(); 135 136 static void printSystemConfig(ostream& out); 137 138 private: 139 // configuration parameters 140 static int m_random_seed; 141 static bool m_randomization; 142 static Tick m_clock; 143 static int m_block_size_bytes; 144 static int m_block_size_bits; 145 static uint64 m_memory_size_bytes; 146 static int m_memory_size_bits; 147 148 static Network* m_network_ptr; 149 150 public: 151 static Profiler* m_profiler_ptr; 152 static Tracer* m_tracer_ptr; 153 static MemoryVector* m_mem_vec_ptr; 154}; 155 156inline ostream& 157operator<<(ostream& out, const RubySystem& obj) 158{ 159 //obj.print(out); 160 out << flush; 161 return out; 162} 163 164class RubyExitCallback : public Callback 165{ 166 private: 167 string stats_filename; 168 169 public: 170 virtual ~RubyExitCallback() {} 171 172 RubyExitCallback(const string& _stats_filename) 173 { 174 stats_filename = _stats_filename; 175 } 176 177 virtual void process(); 178}; 179 180#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ 181 182 183 184