RubySystem.hh revision 9206
15124Sgblack@eecs.umich.edu/* 25124Sgblack@eecs.umich.edu * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 35124Sgblack@eecs.umich.edu * All rights reserved. 45124Sgblack@eecs.umich.edu * 55124Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 65124Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 75124Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 85124Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 95124Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 105124Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 115124Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 125124Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 135124Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 145124Sgblack@eecs.umich.edu * this software without specific prior written permission. 155124Sgblack@eecs.umich.edu * 165124Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175124Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185124Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195124Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205124Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215124Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225124Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235124Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245124Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255124Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265124Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275124Sgblack@eecs.umich.edu */ 285124Sgblack@eecs.umich.edu 295124Sgblack@eecs.umich.edu/* 305124Sgblack@eecs.umich.edu * Contains all of the various parts of the system we are simulating. 315124Sgblack@eecs.umich.edu * Performs allocation, deallocation, and setup of all the major 325124Sgblack@eecs.umich.edu * components of the system 335124Sgblack@eecs.umich.edu */ 345124Sgblack@eecs.umich.edu 355124Sgblack@eecs.umich.edu#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__ 365124Sgblack@eecs.umich.edu#define __MEM_RUBY_SYSTEM_SYSTEM_HH__ 375124Sgblack@eecs.umich.edu 385124Sgblack@eecs.umich.edu#include "base/callback.hh" 395124Sgblack@eecs.umich.edu#include "mem/ruby/common/Global.hh" 405124Sgblack@eecs.umich.edu#include "mem/ruby/recorder/CacheRecorder.hh" 415124Sgblack@eecs.umich.edu#include "mem/ruby/slicc_interface/AbstractController.hh" 425124Sgblack@eecs.umich.edu#include "mem/ruby/system/MemoryVector.hh" 435124Sgblack@eecs.umich.edu#include "mem/ruby/system/SparseMemory.hh" 445124Sgblack@eecs.umich.edu#include "params/RubySystem.hh" 455124Sgblack@eecs.umich.edu#include "sim/clocked_object.hh" 465124Sgblack@eecs.umich.edu 475124Sgblack@eecs.umich.educlass Network; 485124Sgblack@eecs.umich.educlass Profiler; 495124Sgblack@eecs.umich.educlass MemoryControl; 505124Sgblack@eecs.umich.edu 515124Sgblack@eecs.umich.educlass RubySystem : public ClockedObject 525124Sgblack@eecs.umich.edu{ 535124Sgblack@eecs.umich.edu public: 545124Sgblack@eecs.umich.edu class RubyEvent : public Event 555124Sgblack@eecs.umich.edu { 565124Sgblack@eecs.umich.edu public: 575124Sgblack@eecs.umich.edu RubyEvent(RubySystem* _ruby_system) 585124Sgblack@eecs.umich.edu { 595124Sgblack@eecs.umich.edu ruby_system = _ruby_system; 605124Sgblack@eecs.umich.edu } 615124Sgblack@eecs.umich.edu private: 625124Sgblack@eecs.umich.edu void process(); 635124Sgblack@eecs.umich.edu 645124Sgblack@eecs.umich.edu RubySystem* ruby_system; 655124Sgblack@eecs.umich.edu }; 665124Sgblack@eecs.umich.edu 675124Sgblack@eecs.umich.edu friend class RubyEvent; 685124Sgblack@eecs.umich.edu 695124Sgblack@eecs.umich.edu typedef RubySystemParams Params; 705124Sgblack@eecs.umich.edu RubySystem(const Params *p); 715124Sgblack@eecs.umich.edu ~RubySystem(); 725124Sgblack@eecs.umich.edu 735124Sgblack@eecs.umich.edu // config accessors 745124Sgblack@eecs.umich.edu static int getRandomSeed() { return m_random_seed; } 755124Sgblack@eecs.umich.edu static int getRandomization() { return m_randomization; } 765124Sgblack@eecs.umich.edu static int getBlockSizeBytes() { return m_block_size_bytes; } 775124Sgblack@eecs.umich.edu static int getBlockSizeBits() { return m_block_size_bits; } 785124Sgblack@eecs.umich.edu static uint64 getMemorySizeBytes() { return m_memory_size_bytes; } 795124Sgblack@eecs.umich.edu static int getMemorySizeBits() { return m_memory_size_bits; } 805124Sgblack@eecs.umich.edu Cycles getTime() const { return curCycle(); } 815124Sgblack@eecs.umich.edu 825124Sgblack@eecs.umich.edu // Public Methods 835124Sgblack@eecs.umich.edu static Network* 845124Sgblack@eecs.umich.edu getNetwork() 855124Sgblack@eecs.umich.edu { 865124Sgblack@eecs.umich.edu assert(m_network_ptr != NULL); 875124Sgblack@eecs.umich.edu return m_network_ptr; 885124Sgblack@eecs.umich.edu } 895124Sgblack@eecs.umich.edu 905124Sgblack@eecs.umich.edu Profiler* 915124Sgblack@eecs.umich.edu getProfiler() 925124Sgblack@eecs.umich.edu { 935124Sgblack@eecs.umich.edu assert(m_profiler_ptr != NULL); 945124Sgblack@eecs.umich.edu return m_profiler_ptr; 955124Sgblack@eecs.umich.edu } 965237Sgblack@eecs.umich.edu 975237Sgblack@eecs.umich.edu static MemoryVector* 985124Sgblack@eecs.umich.edu getMemoryVector() 995124Sgblack@eecs.umich.edu { 1005124Sgblack@eecs.umich.edu assert(m_mem_vec_ptr != NULL); 1015124Sgblack@eecs.umich.edu return m_mem_vec_ptr; 1025124Sgblack@eecs.umich.edu } 1035130Sgblack@eecs.umich.edu 1045124Sgblack@eecs.umich.edu static void printStats(std::ostream& out); 1055124Sgblack@eecs.umich.edu void clearStats() const; 1065124Sgblack@eecs.umich.edu 1075124Sgblack@eecs.umich.edu uint64 getInstructionCount(int thread) { return 1; } 1085130Sgblack@eecs.umich.edu 1095124Sgblack@eecs.umich.edu void print(std::ostream& out) const; 1105124Sgblack@eecs.umich.edu 1115124Sgblack@eecs.umich.edu void serialize(std::ostream &os); 1125124Sgblack@eecs.umich.edu void unserialize(Checkpoint *cp, const std::string §ion); 1135130Sgblack@eecs.umich.edu void process(); 1145124Sgblack@eecs.umich.edu void startup(); 1155124Sgblack@eecs.umich.edu 1165124Sgblack@eecs.umich.edu void registerNetwork(Network*); 1175237Sgblack@eecs.umich.edu void registerProfiler(Profiler*); 1185237Sgblack@eecs.umich.edu void registerAbstractController(AbstractController*); 1195237Sgblack@eecs.umich.edu void registerSparseMemory(SparseMemory*); 1205237Sgblack@eecs.umich.edu void registerMemController(MemoryControl *mc); 1215245Sgblack@eecs.umich.edu 1225237Sgblack@eecs.umich.edu bool eventQueueEmpty() { return eventq->empty(); } 1235237Sgblack@eecs.umich.edu void enqueueRubyEvent(Tick tick) 1245237Sgblack@eecs.umich.edu { 1255237Sgblack@eecs.umich.edu RubyEvent* e = new RubyEvent(this); 1265237Sgblack@eecs.umich.edu schedule(e, tick); 1275245Sgblack@eecs.umich.edu } 1285237Sgblack@eecs.umich.edu 1295237Sgblack@eecs.umich.edu private: 1305124Sgblack@eecs.umich.edu // Private copy constructor and assignment operator 1315124Sgblack@eecs.umich.edu RubySystem(const RubySystem& obj); 1325124Sgblack@eecs.umich.edu RubySystem& operator=(const RubySystem& obj); 1335124Sgblack@eecs.umich.edu 1345124Sgblack@eecs.umich.edu void init(); 1355124Sgblack@eecs.umich.edu 1365184Sgblack@eecs.umich.edu static void printSystemConfig(std::ostream& out); 1375184Sgblack@eecs.umich.edu void readCompressedTrace(std::string filename, 1385124Sgblack@eecs.umich.edu uint8*& raw_data, 1395124Sgblack@eecs.umich.edu uint64& uncompressed_trace_size); 1405124Sgblack@eecs.umich.edu void writeCompressedTrace(uint8* raw_data, std::string file, 1415124Sgblack@eecs.umich.edu uint64 uncompressed_trace_size); 1425188Sgblack@eecs.umich.edu 1435188Sgblack@eecs.umich.edu private: 1445124Sgblack@eecs.umich.edu // configuration parameters 1455124Sgblack@eecs.umich.edu static int m_random_seed; 1465124Sgblack@eecs.umich.edu static bool m_randomization; 1475124Sgblack@eecs.umich.edu static int m_block_size_bytes; 1485124Sgblack@eecs.umich.edu static int m_block_size_bits; 1495124Sgblack@eecs.umich.edu static uint64 m_memory_size_bytes; 1505124Sgblack@eecs.umich.edu static int m_memory_size_bits; 1515124Sgblack@eecs.umich.edu static Network* m_network_ptr; 1525124Sgblack@eecs.umich.edu 1535184Sgblack@eecs.umich.edu MemoryControl *m_memory_controller; 1545184Sgblack@eecs.umich.edu 1555124Sgblack@eecs.umich.edu public: 1565124Sgblack@eecs.umich.edu static Profiler* m_profiler_ptr; 1575184Sgblack@eecs.umich.edu static MemoryVector* m_mem_vec_ptr; 1585124Sgblack@eecs.umich.edu std::vector<AbstractController*> m_abs_cntrl_vec; 1595124Sgblack@eecs.umich.edu bool m_warmup_enabled; 1605124Sgblack@eecs.umich.edu bool m_cooldown_enabled; 1615124Sgblack@eecs.umich.edu CacheRecorder* m_cache_recorder; 1625124Sgblack@eecs.umich.edu std::vector<SparseMemory*> m_sparse_memory_vector; 1635188Sgblack@eecs.umich.edu}; 1645188Sgblack@eecs.umich.edu 1655124Sgblack@eecs.umich.eduinline std::ostream& 1665124Sgblack@eecs.umich.eduoperator<<(std::ostream& out, const RubySystem& obj) 1675124Sgblack@eecs.umich.edu{ 1685124Sgblack@eecs.umich.edu //obj.print(out); 1695124Sgblack@eecs.umich.edu out << std::flush; 1705124Sgblack@eecs.umich.edu return out; 171} 172 173class RubyExitCallback : public Callback 174{ 175 private: 176 std::string stats_filename; 177 178 public: 179 virtual ~RubyExitCallback() {} 180 181 RubyExitCallback(const std::string& _stats_filename) 182 { 183 stats_filename = _stats_filename; 184 } 185 186 virtual void process(); 187}; 188 189#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ 190