From 08c1af1b16150e68c17acf877249b5017a08f975 Mon Sep 17 00:00:00 2001 From: Vishnu Ramadas Date: Thu, 12 Oct 2023 14:49:06 -0500 Subject: [PATCH 1/2] mem-ruby: Use RubyPort vector to access Ruby in cache recorder Previously, the cache recorder used a vector of sequencer pointers to access Ruby objects. A recent commit updated the cache recorder to also maintain a vector of GPUCoalescer pointers in order for GPUs to support flushin. This added redundant code to the cache recorder. This commit replaces the sequencer and GPUCoalescer vectors with a vector of RubyPort pointers so that the code does not contain redundant lines Change-Id: Id5da33fb870f17bb9daef816cc43c0bcd70a8706 --- src/mem/ruby/system/CacheRecorder.cc | 65 ++++++---------------------- src/mem/ruby/system/CacheRecorder.hh | 21 ++------- src/mem/ruby/system/RubySystem.cc | 50 +++++++-------------- 3 files changed, 33 insertions(+), 103 deletions(-) diff --git a/src/mem/ruby/system/CacheRecorder.cc b/src/mem/ruby/system/CacheRecorder.cc index 057b6aa041..3326856849 100644 --- a/src/mem/ruby/system/CacheRecorder.cc +++ b/src/mem/ruby/system/CacheRecorder.cc @@ -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& seq_map, - std::vector& coal_map, + std::vector& 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& 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); diff --git a/src/mem/ruby/system/CacheRecorder.hh b/src/mem/ruby/system/CacheRecorder.hh index e94dfad97a..021da6a4da 100644 --- a/src/mem/ruby/system/CacheRecorder.hh +++ b/src/mem/ruby/system/CacheRecorder.hh @@ -38,7 +38,6 @@ #include #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& SequencerMap, - std::vector& CoalescerMap, + std::vector& ruby_port_map, uint64_t block_size_bytes); -#else - CacheRecorder(uint8_t* uncompressed_trace, - uint64_t uncompressed_trace_size, - std::vector& 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 m_records; uint8_t* m_uncompressed_trace; uint64_t m_uncompressed_trace_size; - std::vector m_seq_map; -#if BUILD_GPU - std::vector m_coalescer_map; -#endif + std::vector m_ruby_port_map; uint64_t m_bytes_read; uint64_t m_records_read; uint64_t m_records_flushed; diff --git a/src/mem/ruby/system/RubySystem.cc b/src/mem/ruby/system/RubySystem.cc index 32dec7b9e0..109fd43051 100644 --- a/src/mem/ruby/system/RubySystem.cc +++ b/src/mem/ruby/system/RubySystem.cc @@ -177,44 +177,32 @@ RubySystem::makeCacheRecorder(uint8_t *uncompressed_trace, uint64_t cache_trace_size, uint64_t block_size_bytes) { - std::vector sequencer_map; -#if BUILD_GPU - std::vector coalescer_map; - GPUCoalescer* coalescer_ptr = NULL; -#endif - Sequencer* sequencer_ptr = NULL; + std::vector 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 From 8d54a5cbaba50739889056293905930fea4ee1f4 Mon Sep 17 00:00:00 2001 From: Vishnu Ramadas Date: Thu, 12 Oct 2023 14:53:29 -0500 Subject: [PATCH 2/2] mem-ruby: Remove BUILD_GPU guards from ruby coalescer models A previous commit added BUILD_GPU guards to gpu coalescer models since a related cache recorder commit added GPU support. This is no longer needed since the cache recorder moved to using a vector of RubyPorts instead of Sequencer/GPUCoalescer pointers. This commit removes BUILD_GPU guards from the Ruby coalescer models Change-Id: I23a7957d82524d6cd3483d22edfb35ac51796eca --- src/mem/ruby/slicc_interface/AbstractController.hh | 2 -- src/mem/ruby/system/GPUCoalescer.hh | 5 ----- src/mem/ruby/system/VIPERCoalescer.hh | 5 ----- 3 files changed, 12 deletions(-) diff --git a/src/mem/ruby/slicc_interface/AbstractController.hh b/src/mem/ruby/slicc_interface/AbstractController.hh index 7d93644bd8..72b679d6cf 100644 --- a/src/mem/ruby/slicc_interface/AbstractController.hh +++ b/src/mem/ruby/slicc_interface/AbstractController.hh @@ -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 diff --git a/src/mem/ruby/system/GPUCoalescer.hh b/src/mem/ruby/system/GPUCoalescer.hh index 3f936b4b41..d6db5c00ba 100644 --- a/src/mem/ruby/system/GPUCoalescer.hh +++ b/src/mem/ruby/system/GPUCoalescer.hh @@ -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 #include @@ -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__ diff --git a/src/mem/ruby/system/VIPERCoalescer.hh b/src/mem/ruby/system/VIPERCoalescer.hh index d185620244..c7e21e946b 100644 --- a/src/mem/ruby/system/VIPERCoalescer.hh +++ b/src/mem/ruby/system/VIPERCoalescer.hh @@ -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 #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__