mem-ruby: Update cache recorder to use RubyPort and remove BUILD_GPU guards (#448)

This PR updates cache recorder to use a vector of RubyPorts for cache
cooldown and warmup instead of Sequencer or GPUCoalescer vectors (refer
to issue #403 for more details). It also removes the extra guards that
were added in #377 to prevent compile-time failures in non-GPU builds.
This commit is contained in:
Matthew Poremba
2023-10-13 14:36:45 -07:00
committed by GitHub
6 changed files with 33 additions and 115 deletions

View File

@@ -70,9 +70,7 @@ namespace ruby
{
class Network;
#ifdef BUILD_GPU
class GPUCoalescer;
#endif
class DMASequencer;
// used to communicate that an in_port peeked the wrong message type

View File

@@ -31,7 +31,6 @@
#include "debug/RubyCacheTrace.hh"
#include "mem/packet.hh"
#include "mem/ruby/system/GPUCoalescer.hh"
#include "mem/ruby/system/RubySystem.hh"
#include "mem/ruby/system/Sequencer.hh"
#include "sim/sim_exit.hh"
@@ -57,29 +56,16 @@ CacheRecorder::CacheRecorder()
{
}
#if BUILD_GPU
CacheRecorder::CacheRecorder(uint8_t* uncompressed_trace,
uint64_t uncompressed_trace_size,
std::vector<Sequencer*>& seq_map,
std::vector<GPUCoalescer*>& coal_map,
std::vector<RubyPort*>& ruby_port_map,
uint64_t block_size_bytes)
: m_uncompressed_trace(uncompressed_trace),
m_uncompressed_trace_size(uncompressed_trace_size),
m_seq_map(seq_map), m_coalescer_map(coal_map), m_bytes_read(0),
m_records_read(0), m_records_flushed(0),
m_block_size_bytes(block_size_bytes)
#else
CacheRecorder::CacheRecorder(uint8_t* uncompressed_trace,
uint64_t uncompressed_trace_size,
std::vector<Sequencer*>& seq_map,
uint64_t block_size_bytes)
: m_uncompressed_trace(uncompressed_trace),
m_uncompressed_trace_size(uncompressed_trace_size),
m_seq_map(seq_map), m_bytes_read(0),
m_ruby_port_map(ruby_port_map), m_bytes_read(0),
m_records_read(0), m_records_flushed(0),
m_block_size_bytes(block_size_bytes)
#endif
{
if (m_uncompressed_trace != NULL) {
if (m_block_size_bytes < RubySystem::getBlockSizeBytes()) {
@@ -98,10 +84,7 @@ CacheRecorder::~CacheRecorder()
delete [] m_uncompressed_trace;
m_uncompressed_trace = NULL;
}
m_seq_map.clear();
#if BUILD_GPU
m_coalescer_map.clear();
#endif
m_ruby_port_map.clear();
}
void
@@ -115,22 +98,12 @@ CacheRecorder::enqueueNextFlushRequest()
Request::funcRequestorId);
MemCmd::Command requestType = MemCmd::FlushReq;
Packet *pkt = new Packet(req, requestType);
pkt->req->setReqInstSeqNum(m_records_flushed);
Sequencer* m_sequencer_ptr = m_seq_map[rec->m_cntrl_id];
#if BUILD_GPU
GPUCoalescer* m_coal_ptr = m_coalescer_map[rec->m_cntrl_id];
#endif
assert(m_sequencer_ptr != NULL);
#if BUILD_GPU
if (m_coal_ptr == NULL)
m_sequencer_ptr->makeRequest(pkt);
else {
pkt->req->setReqInstSeqNum(m_records_flushed - 1);
m_coal_ptr->makeRequest(pkt);
}
#else
m_sequencer_ptr->makeRequest(pkt);
#endif
RubyPort* m_ruby_port_ptr = m_ruby_port_map[rec->m_cntrl_id];
assert(m_ruby_port_ptr != NULL);
m_ruby_port_ptr->makeRequest(pkt);
DPRINTF(RubyCacheTrace, "Flushing %s\n", *rec);
@@ -178,23 +151,13 @@ CacheRecorder::enqueueNextFetchRequest()
Packet *pkt = new Packet(req, requestType);
pkt->dataStatic(traceRecord->m_data + rec_bytes_read);
pkt->req->setReqInstSeqNum(m_records_read);
Sequencer* m_sequencer_ptr = m_seq_map[traceRecord->m_cntrl_id];
#if BUILD_GPU
GPUCoalescer* m_coal_ptr;
m_coal_ptr = m_coalescer_map[traceRecord->m_cntrl_id];
#endif
assert(m_sequencer_ptr != NULL);
#if BUILD_GPU
if (m_coal_ptr == NULL)
m_sequencer_ptr->makeRequest(pkt);
else {
pkt->req->setReqInstSeqNum(m_records_read);
m_coal_ptr->makeRequest(pkt);
}
#else
m_sequencer_ptr->makeRequest(pkt);
#endif
RubyPort* m_ruby_port_ptr =
m_ruby_port_map[traceRecord->m_cntrl_id];
assert(m_ruby_port_ptr != NULL);
m_ruby_port_ptr->makeRequest(pkt);
}
m_bytes_read += (sizeof(TraceRecord) + m_block_size_bytes);

View File

@@ -38,7 +38,6 @@
#include <vector>
#include "base/types.hh"
#include "config/build_gpu.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/common/DataBlock.hh"
#include "mem/ruby/common/TypeDefines.hh"
@@ -51,10 +50,7 @@ namespace ruby
{
class Sequencer;
#if BUILD_GPU
class GPUCoalescer;
#endif
class RubyPort;
/*!
* Class for recording cache contents. Note that the last element of the
* class is an array of length zero. It is used for creating variable
@@ -80,18 +76,10 @@ class CacheRecorder
CacheRecorder();
~CacheRecorder();
#if BUILD_GPU
CacheRecorder(uint8_t* uncompressed_trace,
uint64_t uncompressed_trace_size,
std::vector<Sequencer*>& SequencerMap,
std::vector<GPUCoalescer*>& CoalescerMap,
std::vector<RubyPort*>& ruby_port_map,
uint64_t block_size_bytes);
#else
CacheRecorder(uint8_t* uncompressed_trace,
uint64_t uncompressed_trace_size,
std::vector<Sequencer*>& SequencerMap,
uint64_t block_size_bytes);
#endif
void addRecord(int cntrl, Addr data_addr, Addr pc_addr,
RubyRequestType type, Tick time, DataBlock& data);
@@ -126,10 +114,7 @@ class CacheRecorder
std::vector<TraceRecord*> m_records;
uint8_t* m_uncompressed_trace;
uint64_t m_uncompressed_trace_size;
std::vector<Sequencer*> m_seq_map;
#if BUILD_GPU
std::vector<GPUCoalescer*> m_coalescer_map;
#endif
std::vector<RubyPort*> m_ruby_port_map;
uint64_t m_bytes_read;
uint64_t m_records_read;
uint64_t m_records_flushed;

View File

@@ -32,10 +32,6 @@
#ifndef __MEM_RUBY_SYSTEM_GPU_COALESCER_HH__
#define __MEM_RUBY_SYSTEM_GPU_COALESCER_HH__
#include "config/build_gpu.hh"
#if BUILD_GPU
#include <iostream>
#include <unordered_map>
@@ -550,5 +546,4 @@ operator<<(std::ostream& out, const GPUCoalescer& obj)
} // namespace ruby
} // namespace gem5
#endif // BUILD_GPU
#endif // __MEM_RUBY_SYSTEM_GPU_COALESCER_HH__

View File

@@ -177,44 +177,32 @@ RubySystem::makeCacheRecorder(uint8_t *uncompressed_trace,
uint64_t cache_trace_size,
uint64_t block_size_bytes)
{
std::vector<Sequencer*> sequencer_map;
#if BUILD_GPU
std::vector<GPUCoalescer*> coalescer_map;
GPUCoalescer* coalescer_ptr = NULL;
#endif
Sequencer* sequencer_ptr = NULL;
std::vector<RubyPort*> ruby_port_map;
RubyPort* ruby_port_ptr = NULL;
for (int cntrl = 0; cntrl < m_abs_cntrl_vec.size(); cntrl++) {
sequencer_map.push_back(m_abs_cntrl_vec[cntrl]->getCPUSequencer());
#if BUILD_GPU
coalescer_map.push_back(m_abs_cntrl_vec[cntrl]->getGPUCoalescer());
#endif
if (sequencer_ptr == NULL) {
sequencer_ptr = sequencer_map[cntrl];
if (m_abs_cntrl_vec[cntrl]->getGPUCoalescer() != NULL) {
ruby_port_map.push_back(
(RubyPort*)m_abs_cntrl_vec[cntrl]->getGPUCoalescer());
} else {
ruby_port_map.push_back(
(RubyPort*)m_abs_cntrl_vec[cntrl]->getCPUSequencer());
}
#if BUILD_GPU
if (coalescer_ptr == NULL) {
coalescer_ptr = coalescer_map[cntrl];
if (ruby_port_ptr == NULL) {
ruby_port_ptr = ruby_port_map[cntrl];
}
#endif
}
assert(sequencer_ptr != NULL);
assert(ruby_port_ptr != NULL);
for (int cntrl = 0; cntrl < m_abs_cntrl_vec.size(); cntrl++) {
if (sequencer_map[cntrl] == NULL) {
sequencer_map[cntrl] = sequencer_ptr;
if (ruby_port_map[cntrl] == NULL) {
ruby_port_map[cntrl] = ruby_port_ptr;
} else {
ruby_port_ptr = ruby_port_map[cntrl];
}
#if BUILD_GPU
if (coalescer_map[cntrl] == NULL) {
coalescer_map[cntrl] = coalescer_ptr;
}
#endif
}
// Remove the old CacheRecorder if it's still hanging about.
@@ -223,15 +211,9 @@ RubySystem::makeCacheRecorder(uint8_t *uncompressed_trace,
}
// Create the CacheRecorder and record the cache trace
#if BUILD_GPU
m_cache_recorder = new CacheRecorder(uncompressed_trace, cache_trace_size,
sequencer_map, coalescer_map,
ruby_port_map,
block_size_bytes);
#else
m_cache_recorder = new CacheRecorder(uncompressed_trace, cache_trace_size,
sequencer_map,
block_size_bytes);
#endif
}
void

View File

@@ -32,10 +32,6 @@
#ifndef __MEM_RUBY_SYSTEM_VIPERCOALESCER_HH__
#define __MEM_RUBY_SYSTEM_VIPERCOALESCER_HH__
#include "config/build_gpu.hh"
#if BUILD_GPU
#include <iostream>
#include "mem/ruby/common/Address.hh"
@@ -96,5 +92,4 @@ class VIPERCoalescer : public GPUCoalescer
} // namespace ruby
} // namespace gem5
#endif // BUILD_GPU
#endif //__MEM_RUBY_SYSTEM_VIPERCOALESCER_HH__