ruby: Fix RubySystem warm-up and cool-down scope

The processes of warming up and cooling down Ruby caches are simulation-wide
processes, not just RubySystem instance-specific processes. Thus, the warm-up
and cool-down variables should be globally visible to any Ruby components
participating in either process. Make these variables static members and track
the warm-up and cool-down processes as appropriate.

This patch also has two side benefits:
1) It removes references to the RubySystem g_system_ptr, which are problematic
for allowing multiple RubySystem instances in a single simulation. Warmup and
cooldown variables being static (global) reduces the need for instance-specific
dereferences through the RubySystem.
2) From the AbstractController, it removes local RubySystem pointers, which are
used inconsistently with other uses of the RubySystem: 11 other uses reference
the RubySystem with the g_system_ptr. Only sequencers have local pointers.
This commit is contained in:
Joel Hestness 2015-05-19 10:56:51 -05:00
parent 99d3fa5945
commit 0479569f67
6 changed files with 24 additions and 19 deletions

View file

@ -191,7 +191,7 @@ MessageBuffer::enqueue(MsgPtr message, Cycles delta)
}
// If running a cache trace, don't worry about the last arrival checks
if (!g_system_ptr->m_warmup_enabled) {
if (!RubySystem::getWarmupEnabled()) {
m_last_arrival_time = arrival_time;
}

View file

@ -40,8 +40,7 @@ AbstractController::AbstractController(const Params *p)
m_transitions_per_cycle(p->transitions_per_cycle),
m_buffer_size(p->buffer_size), m_recycle_latency(p->recycle_latency),
memoryPort(csprintf("%s.memory", name()), this, ""),
m_responseFromMemory_ptr(new MessageBuffer()),
m_rubySystem(p->ruby_system)
m_responseFromMemory_ptr(new MessageBuffer())
{
// Set the sender pointer of the response message buffer from the
// memory controller.
@ -219,7 +218,7 @@ AbstractController::queueMemoryRead(const MachineID &id, Address addr,
pkt->pushSenderState(s);
// Use functional rather than timing accesses during warmup
if (m_rubySystem->m_warmup_enabled) {
if (RubySystem::getWarmupEnabled()) {
memoryPort.sendFunctional(pkt);
recvTimingResp(pkt);
return;
@ -246,7 +245,7 @@ AbstractController::queueMemoryWrite(const MachineID &id, Address addr,
pkt->pushSenderState(s);
// Use functional rather than timing accesses during warmup
if (m_rubySystem->m_warmup_enabled) {
if (RubySystem::getWarmupEnabled()) {
memoryPort.sendFunctional(pkt);
recvTimingResp(pkt);
return;

View file

@ -205,9 +205,6 @@ class AbstractController : public MemObject, public Consumer
// memory controller.
MessageBuffer *m_responseFromMemory_ptr;
// Needed so we know if we are warming up
RubySystem *m_rubySystem;
// State that is stored in packets sent to the memory controller.
struct SenderState : public Packet::SenderState
{

View file

@ -525,7 +525,7 @@ Sequencer::hitCallback(SequencerRequest* srequest, DataBlock& data,
request_address, total_latency);
// update the data unless it is a non-data-carrying flush
if (g_system_ptr->m_warmup_enabled) {
if (RubySystem::getWarmupEnabled()) {
data.setData(pkt->getConstPtr<uint8_t>(),
request_address.getOffset(), pkt->getSize());
} else if (!pkt->isFlush()) {
@ -557,12 +557,12 @@ Sequencer::hitCallback(SequencerRequest* srequest, DataBlock& data,
delete srequest;
if (g_system_ptr->m_warmup_enabled) {
if (RubySystem::getWarmupEnabled()) {
assert(pkt->req);
delete pkt->req;
delete pkt;
g_system_ptr->m_cache_recorder->enqueueNextFetchRequest();
} else if (g_system_ptr->m_cooldown_enabled) {
} else if (RubySystem::getCooldownEnabled()) {
delete pkt;
g_system_ptr->m_cache_recorder->enqueueNextFlushRequest();
} else {

View file

@ -49,6 +49,11 @@ bool RubySystem::m_randomization;
uint32_t RubySystem::m_block_size_bytes;
uint32_t RubySystem::m_block_size_bits;
uint32_t RubySystem::m_memory_size_bits;
bool RubySystem::m_warmup_enabled = false;
// To look forward to allowing multiple RubySystem instances, track the number
// of RubySystems that need to be warmed up on checkpoint restore.
unsigned RubySystem::m_systems_to_warmup = 0;
bool RubySystem::m_cooldown_enabled = false;
RubySystem::RubySystem(const Params *p)
: ClockedObject(p), m_access_backing_store(p->access_backing_store)
@ -65,9 +70,6 @@ RubySystem::RubySystem(const Params *p)
m_block_size_bits = floorLog2(m_block_size_bytes);
m_memory_size_bits = p->memory_size_bits;
m_warmup_enabled = false;
m_cooldown_enabled = false;
// Setup the global variables used in Ruby
g_system_ptr = this;
@ -252,6 +254,7 @@ RubySystem::unserialize(Checkpoint *cp, const string &section)
readCompressedTrace(cache_trace_file, uncompressed_trace,
cache_trace_size);
m_warmup_enabled = true;
m_systems_to_warmup++;
vector<Sequencer*> sequencer_map;
Sequencer* t = NULL;
@ -307,7 +310,10 @@ RubySystem::startup()
delete m_cache_recorder;
m_cache_recorder = NULL;
m_warmup_enabled = false;
m_systems_to_warmup--;
if (m_systems_to_warmup == 0) {
m_warmup_enabled = false;
}
// Restore eventq head
eventq_head = eventq->replaceHead(eventq_head);
@ -322,9 +328,9 @@ RubySystem::startup()
void
RubySystem::RubyEvent::process()
{
if (ruby_system->m_warmup_enabled) {
if (RubySystem::getWarmupEnabled()) {
ruby_system->m_cache_recorder->enqueueNextFetchRequest();
} else if (ruby_system->m_cooldown_enabled) {
} else if (RubySystem::getCooldownEnabled()) {
ruby_system->m_cache_recorder->enqueueNextFlushRequest();
}
}

View file

@ -74,6 +74,8 @@ class RubySystem : public ClockedObject
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; }
static bool getWarmupEnabled() { return m_warmup_enabled; }
static bool getCooldownEnabled() { return m_cooldown_enabled; }
SimpleMemory *getPhysMem() { return m_phys_mem; }
const bool getAccessBackingStore() { return m_access_backing_store; }
@ -125,6 +127,9 @@ class RubySystem : public ClockedObject
static uint32_t m_block_size_bytes;
static uint32_t m_block_size_bits;
static uint32_t m_memory_size_bits;
static bool m_warmup_enabled;
static unsigned m_systems_to_warmup;
static bool m_cooldown_enabled;
SimpleMemory *m_phys_mem;
const bool m_access_backing_store;
@ -133,8 +138,6 @@ class RubySystem : public ClockedObject
public:
Profiler* m_profiler;
bool m_warmup_enabled;
bool m_cooldown_enabled;
CacheRecorder* m_cache_recorder;
};