From a19667427a96c560b243ffbadbba3b7f4f6db2b4 Mon Sep 17 00:00:00 2001 From: Vishnu Ramadas Date: Thu, 5 Oct 2023 18:59:54 -0500 Subject: [PATCH] mem-ruby: Add BUILD_GPU guard to ruby cooldown and warmup phases Ruby was recently updated to support flushes and warmup for GPUs. Since this support uses the GPUCoalescer, non-GPU builds face a compile time issue. This is because GPU code is not built for non-GPU builds. This commit addes "#if BUILD_GPU" guards around the GPU-related code in common files like AbstractController.hh, CacheRecorder.*, RubySystem.cc, GPUCoalescer.hh, and VIPERCoalescer.hh. This support allows GPU builds to use flushing while non-GPU builds compile without problems Change-Id: If8ee4ff881fe154553289e8c00881ee1b6e3f113 --- .../slicc_interface/AbstractController.hh | 2 ++ src/mem/ruby/system/CacheRecorder.cc | 27 +++++++++++++++++++ src/mem/ruby/system/CacheRecorder.hh | 12 +++++++++ src/mem/ruby/system/GPUCoalescer.hh | 5 ++++ src/mem/ruby/system/RubySystem.cc | 16 ++++++++++- src/mem/ruby/system/VIPERCoalescer.hh | 5 ++++ 6 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/mem/ruby/slicc_interface/AbstractController.hh b/src/mem/ruby/slicc_interface/AbstractController.hh index 72b679d6cf..7d93644bd8 100644 --- a/src/mem/ruby/slicc_interface/AbstractController.hh +++ b/src/mem/ruby/slicc_interface/AbstractController.hh @@ -70,7 +70,9 @@ 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/CacheRecorder.cc b/src/mem/ruby/system/CacheRecorder.cc index ec552c07c5..057b6aa041 100644 --- a/src/mem/ruby/system/CacheRecorder.cc +++ b/src/mem/ruby/system/CacheRecorder.cc @@ -57,6 +57,7 @@ CacheRecorder::CacheRecorder() { } +#if BUILD_GPU CacheRecorder::CacheRecorder(uint8_t* uncompressed_trace, uint64_t uncompressed_trace_size, std::vector& seq_map, @@ -67,6 +68,18 @@ CacheRecorder::CacheRecorder(uint8_t* uncompressed_trace, 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_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()) { @@ -86,7 +99,9 @@ CacheRecorder::~CacheRecorder() m_uncompressed_trace = NULL; } m_seq_map.clear(); +#if BUILD_GPU m_coalescer_map.clear(); +#endif } void @@ -102,14 +117,20 @@ CacheRecorder::enqueueNextFlushRequest() Packet *pkt = new Packet(req, requestType); 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 DPRINTF(RubyCacheTrace, "Flushing %s\n", *rec); @@ -159,15 +180,21 @@ CacheRecorder::enqueueNextFetchRequest() pkt->dataStatic(traceRecord->m_data + rec_bytes_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 } 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 9363e2fde7..e94dfad97a 100644 --- a/src/mem/ruby/system/CacheRecorder.hh +++ b/src/mem/ruby/system/CacheRecorder.hh @@ -38,6 +38,7 @@ #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" @@ -50,7 +51,9 @@ namespace ruby { class Sequencer; +#if BUILD_GPU class GPUCoalescer; +#endif /*! * Class for recording cache contents. Note that the last element of the @@ -77,11 +80,18 @@ class CacheRecorder CacheRecorder(); ~CacheRecorder(); +#if BUILD_GPU CacheRecorder(uint8_t* uncompressed_trace, uint64_t uncompressed_trace_size, std::vector& SequencerMap, std::vector& CoalescerMap, 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); @@ -117,7 +127,9 @@ class CacheRecorder 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 uint64_t m_bytes_read; uint64_t m_records_read; uint64_t m_records_flushed; diff --git a/src/mem/ruby/system/GPUCoalescer.hh b/src/mem/ruby/system/GPUCoalescer.hh index d6db5c00ba..3f936b4b41 100644 --- a/src/mem/ruby/system/GPUCoalescer.hh +++ b/src/mem/ruby/system/GPUCoalescer.hh @@ -32,6 +32,10 @@ #ifndef __MEM_RUBY_SYSTEM_GPU_COALESCER_HH__ #define __MEM_RUBY_SYSTEM_GPU_COALESCER_HH__ +#include "config/build_gpu.hh" + +#if BUILD_GPU + #include #include @@ -546,4 +550,5 @@ 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/RubySystem.cc b/src/mem/ruby/system/RubySystem.cc index 232e337752..32dec7b9e0 100644 --- a/src/mem/ruby/system/RubySystem.cc +++ b/src/mem/ruby/system/RubySystem.cc @@ -178,21 +178,27 @@ RubySystem::makeCacheRecorder(uint8_t *uncompressed_trace, uint64_t block_size_bytes) { std::vector sequencer_map; +#if BUILD_GPU std::vector coalescer_map; - Sequencer* sequencer_ptr = NULL; GPUCoalescer* coalescer_ptr = NULL; +#endif + Sequencer* sequencer_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 BUILD_GPU if (coalescer_ptr == NULL) { coalescer_ptr = coalescer_map[cntrl]; } +#endif } @@ -203,9 +209,11 @@ RubySystem::makeCacheRecorder(uint8_t *uncompressed_trace, sequencer_map[cntrl] = sequencer_ptr; } +#if BUILD_GPU if (coalescer_map[cntrl] == NULL) { coalescer_map[cntrl] = coalescer_ptr; } +#endif } @@ -215,9 +223,15 @@ 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, block_size_bytes); +#else + m_cache_recorder = new CacheRecorder(uncompressed_trace, cache_trace_size, + sequencer_map, + block_size_bytes); +#endif } void diff --git a/src/mem/ruby/system/VIPERCoalescer.hh b/src/mem/ruby/system/VIPERCoalescer.hh index c7e21e946b..d185620244 100644 --- a/src/mem/ruby/system/VIPERCoalescer.hh +++ b/src/mem/ruby/system/VIPERCoalescer.hh @@ -32,6 +32,10 @@ #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" @@ -92,4 +96,5 @@ class VIPERCoalescer : public GPUCoalescer } // namespace ruby } // namespace gem5 +#endif // BUILD_GPU #endif //__MEM_RUBY_SYSTEM_VIPERCOALESCER_HH__