From f378fd5a70d23ac67950aadddf0944238aaf2f41 Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Thu, 9 Jan 2020 22:33:32 +0100 Subject: [PATCH] mem-garnet: Use static allocation in VirtualChannel The input buffer does not need to be dynamically allocated. Change-Id: Ice64f40d2a7e16af325ddb6803e34b3eed2e99db Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24253 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris Tested-by: kokoro --- .../ruby/network/garnet2.0/VirtualChannel.cc | 23 ++++++------------- .../ruby/network/garnet2.0/VirtualChannel.hh | 18 ++++++++------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/mem/ruby/network/garnet2.0/VirtualChannel.cc b/src/mem/ruby/network/garnet2.0/VirtualChannel.cc index 2deee32fd..3b077d4f3 100644 --- a/src/mem/ruby/network/garnet2.0/VirtualChannel.cc +++ b/src/mem/ruby/network/garnet2.0/VirtualChannel.cc @@ -1,6 +1,7 @@ /* - * Copyright (c) 2008 Princeton University + * Copyright (c) 2020 Inria * Copyright (c) 2016 Georgia Institute of Technology + * Copyright (c) 2008 Princeton University * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,19 +32,9 @@ #include "mem/ruby/network/garnet2.0/VirtualChannel.hh" VirtualChannel::VirtualChannel(int id) - : m_enqueue_time(INFINITE_) -{ - m_id = id; - m_input_buffer = new flitBuffer(); - m_vc_state.first = IDLE_; - m_vc_state.second = Cycles(0); - m_output_vc = -1; - m_output_port = -1; -} - -VirtualChannel::~VirtualChannel() + : m_id(id), inputBuffer(), m_vc_state(IDLE_, Cycles(0)), m_output_port(-1), + m_enqueue_time(INFINITE_), m_output_vc(-1) { - delete m_input_buffer; } void @@ -67,9 +58,9 @@ VirtualChannel::set_active(Cycles curTime) bool VirtualChannel::need_stage(flit_stage stage, Cycles time) { - if (m_input_buffer->isReady(time)) { + if (inputBuffer.isReady(time)) { assert(m_vc_state.first == ACTIVE_ && m_vc_state.second <= time); - flit *t_flit = m_input_buffer->peekTopFlit(); + flit *t_flit = inputBuffer.peekTopFlit(); return(t_flit->is_stage(stage, time)); } return false; @@ -78,5 +69,5 @@ VirtualChannel::need_stage(flit_stage stage, Cycles time) uint32_t VirtualChannel::functionalWrite(Packet *pkt) { - return m_input_buffer->functionalWrite(pkt); + return inputBuffer.functionalWrite(pkt); } diff --git a/src/mem/ruby/network/garnet2.0/VirtualChannel.hh b/src/mem/ruby/network/garnet2.0/VirtualChannel.hh index 1deac6195..52963c8ac 100644 --- a/src/mem/ruby/network/garnet2.0/VirtualChannel.hh +++ b/src/mem/ruby/network/garnet2.0/VirtualChannel.hh @@ -1,6 +1,7 @@ /* - * Copyright (c) 2008 Princeton University + * Copyright (c) 2020 Inria * Copyright (c) 2016 Georgia Institute of Technology + * Copyright (c) 2008 Princeton University * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,7 +41,7 @@ class VirtualChannel { public: VirtualChannel(int id); - ~VirtualChannel(); + ~VirtualChannel() = default; bool need_stage(flit_stage stage, Cycles time); void set_idle(Cycles curTime); @@ -54,15 +55,16 @@ class VirtualChannel inline void set_enqueue_time(Cycles time) { m_enqueue_time = time; } inline VC_state_type get_state() { return m_vc_state.first; } - inline bool isReady(Cycles curTime) + inline bool + isReady(Cycles curTime) { - return m_input_buffer->isReady(curTime); + return inputBuffer.isReady(curTime); } inline void insertFlit(flit *t_flit) { - m_input_buffer->insert(t_flit); + inputBuffer.insert(t_flit); } inline void @@ -75,20 +77,20 @@ class VirtualChannel inline flit* peekTopFlit() { - return m_input_buffer->peekTopFlit(); + return inputBuffer.peekTopFlit(); } inline flit* getTopFlit() { - return m_input_buffer->getTopFlit(); + return inputBuffer.getTopFlit(); } uint32_t functionalWrite(Packet *pkt); private: int m_id; - flitBuffer *m_input_buffer; + flitBuffer inputBuffer; std::pair m_vc_state; int m_output_port; Cycles m_enqueue_time; -- 2.30.2