2009-05-11 19:38:43 +02:00
|
|
|
/*
|
2012-01-11 20:48:48 +01:00
|
|
|
* Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
|
2009-05-11 19:38:43 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2010-03-23 02:43:53 +01:00
|
|
|
* Contains all of the various parts of the system we are simulating.
|
|
|
|
* Performs allocation, deallocation, and setup of all the major
|
|
|
|
* components of the system
|
2009-05-11 19:38:43 +02:00
|
|
|
*/
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__
|
|
|
|
#define __MEM_RUBY_SYSTEM_SYSTEM_HH__
|
2009-05-11 19:38:43 +02:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
#include "base/callback.hh"
|
2012-11-02 18:18:25 +01:00
|
|
|
#include "base/output.hh"
|
2015-09-16 18:03:03 +02:00
|
|
|
#include "mem/packet.hh"
|
2014-01-10 23:19:47 +01:00
|
|
|
#include "mem/ruby/profiler/Profiler.hh"
|
2011-07-01 02:49:26 +02:00
|
|
|
#include "mem/ruby/slicc_interface/AbstractController.hh"
|
2014-09-01 23:55:40 +02:00
|
|
|
#include "mem/ruby/system/CacheRecorder.hh"
|
2010-01-30 05:29:17 +01:00
|
|
|
#include "params/RubySystem.hh"
|
2012-09-10 19:21:01 +02:00
|
|
|
#include "sim/clocked_object.hh"
|
2009-05-11 19:38:43 +02:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
class Network;
|
2015-07-10 23:05:24 +02:00
|
|
|
class AbstractController;
|
2009-07-07 00:49:47 +02:00
|
|
|
|
2012-09-10 19:21:01 +02:00
|
|
|
class RubySystem : public ClockedObject
|
2010-03-23 02:43:53 +01:00
|
|
|
{
|
|
|
|
public:
|
2012-01-11 20:48:48 +01:00
|
|
|
class RubyEvent : public Event
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RubyEvent(RubySystem* _ruby_system)
|
|
|
|
{
|
2015-07-10 23:05:23 +02:00
|
|
|
m_ruby_system = _ruby_system;
|
2012-01-11 20:48:48 +01:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
void process();
|
|
|
|
|
2015-07-10 23:05:23 +02:00
|
|
|
RubySystem* m_ruby_system;
|
2012-01-11 20:48:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
friend class RubyEvent;
|
|
|
|
|
2010-01-30 05:29:17 +01:00
|
|
|
typedef RubySystemParams Params;
|
|
|
|
RubySystem(const Params *p);
|
2010-03-23 02:43:53 +01:00
|
|
|
~RubySystem();
|
|
|
|
|
|
|
|
// config accessors
|
|
|
|
static int getRandomization() { return m_randomization; }
|
2013-02-11 04:43:07 +01:00
|
|
|
static uint32_t getBlockSizeBytes() { return m_block_size_bytes; }
|
|
|
|
static uint32_t getBlockSizeBits() { return m_block_size_bits; }
|
|
|
|
static uint32_t getMemorySizeBits() { return m_memory_size_bits; }
|
2015-05-19 17:56:51 +02:00
|
|
|
static bool getWarmupEnabled() { return m_warmup_enabled; }
|
|
|
|
static bool getCooldownEnabled() { return m_cooldown_enabled; }
|
2010-03-23 02:43:53 +01:00
|
|
|
|
2014-11-06 12:42:21 +01:00
|
|
|
SimpleMemory *getPhysMem() { return m_phys_mem; }
|
2015-07-10 23:05:23 +02:00
|
|
|
Cycles getStartCycle() { return m_start_cycle; }
|
2016-01-11 11:52:20 +01:00
|
|
|
bool getAccessBackingStore() { return m_access_backing_store; }
|
2014-11-06 12:42:21 +01:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
// Public Methods
|
|
|
|
Profiler*
|
|
|
|
getProfiler()
|
|
|
|
{
|
2014-01-10 23:19:47 +01:00
|
|
|
assert(m_profiler != NULL);
|
|
|
|
return m_profiler;
|
2010-03-23 02:43:53 +01:00
|
|
|
}
|
|
|
|
|
2015-10-12 10:08:01 +02:00
|
|
|
void regStats() override { m_profiler->regStats(name()); }
|
2014-01-10 23:19:47 +01:00
|
|
|
void collateStats() { m_profiler->collateStats(); }
|
2015-10-12 10:08:01 +02:00
|
|
|
void resetStats() override;
|
2010-03-23 02:43:53 +01:00
|
|
|
|
2015-10-12 10:08:01 +02:00
|
|
|
void memWriteback() override;
|
2015-10-12 10:07:59 +02:00
|
|
|
void serialize(CheckpointOut &cp) const override;
|
|
|
|
void unserialize(CheckpointIn &cp) override;
|
|
|
|
void drainResume() override;
|
2012-01-11 20:48:48 +01:00
|
|
|
void process();
|
2015-10-12 10:08:01 +02:00
|
|
|
void startup() override;
|
2012-10-02 21:35:42 +02:00
|
|
|
bool functionalRead(Packet *ptr);
|
|
|
|
bool functionalWrite(Packet *ptr);
|
2010-08-20 20:46:13 +02:00
|
|
|
|
2011-07-01 02:49:26 +02:00
|
|
|
void registerNetwork(Network*);
|
|
|
|
void registerAbstractController(AbstractController*);
|
|
|
|
|
2012-04-06 22:47:07 +02:00
|
|
|
bool eventQueueEmpty() { return eventq->empty(); }
|
|
|
|
void enqueueRubyEvent(Tick tick)
|
|
|
|
{
|
|
|
|
RubyEvent* e = new RubyEvent(this);
|
|
|
|
schedule(e, tick);
|
|
|
|
}
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
private:
|
|
|
|
// Private copy constructor and assignment operator
|
|
|
|
RubySystem(const RubySystem& obj);
|
|
|
|
RubySystem& operator=(const RubySystem& obj);
|
|
|
|
|
uby: Fix checkpointing and restore
There are 2 problems with the existing checkpoint and restore code in ruby.
The first is that when the event queue is altered by ruby during serialization,
some events that are currently scheduled cannot be found (e.g. the event to
stop simulation that always lives on the queue), causing a panic.
The second is that ruby is sometimes serialized after the memory system,
meaning that the dirty data in its cache is flushed back to memory too late
and so isn't included in the checkpoint.
These are fixed by implementing memory writeback in ruby, using the same
technique of hijacking the event queue, but first descheduling all events that
are currently on it. They are saved, along with their scheduled time, so that
the event queue can be faithfully reconstructed after writeback has finished.
Events with the AutoDelete flag set will delete themselves when they
are descheduled, causing an error when attempting to schedule them again.
This is fixed by simply not recording them when taking them off the queue.
Writeback is still implemented using flushing, so the cache recorder object,
that is created to generate the trace and manage flushing, is kept
around and used during serialization to write the trace to disk.
Committed by: Nilay Vaish <nilay@cs.wisc.edu>
2015-08-04 06:08:40 +02:00
|
|
|
void makeCacheRecorder(uint8_t *uncompressed_trace,
|
2015-08-29 17:19:23 +02:00
|
|
|
uint64_t cache_trace_size,
|
|
|
|
uint64_t block_size_bytes);
|
uby: Fix checkpointing and restore
There are 2 problems with the existing checkpoint and restore code in ruby.
The first is that when the event queue is altered by ruby during serialization,
some events that are currently scheduled cannot be found (e.g. the event to
stop simulation that always lives on the queue), causing a panic.
The second is that ruby is sometimes serialized after the memory system,
meaning that the dirty data in its cache is flushed back to memory too late
and so isn't included in the checkpoint.
These are fixed by implementing memory writeback in ruby, using the same
technique of hijacking the event queue, but first descheduling all events that
are currently on it. They are saved, along with their scheduled time, so that
the event queue can be faithfully reconstructed after writeback has finished.
Events with the AutoDelete flag set will delete themselves when they
are descheduled, causing an error when attempting to schedule them again.
This is fixed by simply not recording them when taking them off the queue.
Writeback is still implemented using flushing, so the cache recorder object,
that is created to generate the trace and manage flushing, is kept
around and used during serialization to write the trace to disk.
Committed by: Nilay Vaish <nilay@cs.wisc.edu>
2015-08-04 06:08:40 +02:00
|
|
|
|
2015-08-28 11:58:44 +02:00
|
|
|
static void readCompressedTrace(std::string filename,
|
|
|
|
uint8_t *&raw_data,
|
2015-08-29 17:19:23 +02:00
|
|
|
uint64_t &uncompressed_trace_size);
|
2015-08-28 11:58:44 +02:00
|
|
|
static void writeCompressedTrace(uint8_t *raw_data, std::string file,
|
2015-08-29 17:19:23 +02:00
|
|
|
uint64_t uncompressed_trace_size);
|
2010-03-23 02:43:53 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
// configuration parameters
|
|
|
|
static bool m_randomization;
|
2013-02-11 04:43:07 +01:00
|
|
|
static uint32_t m_block_size_bytes;
|
|
|
|
static uint32_t m_block_size_bits;
|
|
|
|
static uint32_t m_memory_size_bits;
|
2015-07-10 23:05:23 +02:00
|
|
|
|
2015-05-19 17:56:51 +02:00
|
|
|
static bool m_warmup_enabled;
|
|
|
|
static unsigned m_systems_to_warmup;
|
|
|
|
static bool m_cooldown_enabled;
|
2014-11-06 12:42:21 +01:00
|
|
|
SimpleMemory *m_phys_mem;
|
2015-02-26 16:58:26 +01:00
|
|
|
const bool m_access_backing_store;
|
2010-03-23 02:43:53 +01:00
|
|
|
|
2014-01-10 23:19:47 +01:00
|
|
|
Network* m_network;
|
2012-10-16 00:27:17 +02:00
|
|
|
std::vector<AbstractController *> m_abs_cntrl_vec;
|
2015-07-10 23:05:23 +02:00
|
|
|
Cycles m_start_cycle;
|
2012-07-11 07:51:54 +02:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
public:
|
2014-01-10 23:19:47 +01:00
|
|
|
Profiler* m_profiler;
|
2012-01-11 20:48:48 +01:00
|
|
|
CacheRecorder* m_cache_recorder;
|
2015-07-10 23:05:24 +02:00
|
|
|
std::vector<std::map<uint32_t, AbstractController *> > m_abstract_controls;
|
2010-03-23 02:43:53 +01:00
|
|
|
};
|
|
|
|
|
2014-01-10 23:19:47 +01:00
|
|
|
class RubyStatsCallback : public Callback
|
2010-01-30 05:29:21 +01:00
|
|
|
{
|
|
|
|
private:
|
2015-07-10 23:05:23 +02:00
|
|
|
RubySystem *m_ruby_system;
|
2010-01-30 05:29:21 +01:00
|
|
|
|
|
|
|
public:
|
2014-01-10 23:19:47 +01:00
|
|
|
virtual ~RubyStatsCallback() {}
|
2015-07-10 23:05:23 +02:00
|
|
|
RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {}
|
|
|
|
void process() { m_ruby_system->collateStats(); }
|
2010-01-30 05:29:21 +01:00
|
|
|
};
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__
|