From f5454970577222f2eaf075602c06deb301b15ed1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Tue, 7 Jan 2020 23:44:08 +0100 Subject: [PATCH] mem-garnet: Use static allocation in OutputUnit Use static allocation for the pointers created by OutputUnit. Change-Id: Ica4fd5d4994078764769702311520c9daf8dba72 Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24243 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris Tested-by: kokoro --- src/mem/ruby/network/garnet2.0/OutputUnit.cc | 50 +++++++++----------- src/mem/ruby/network/garnet2.0/OutputUnit.hh | 34 ++++++------- 2 files changed, 38 insertions(+), 46 deletions(-) diff --git a/src/mem/ruby/network/garnet2.0/OutputUnit.cc b/src/mem/ruby/network/garnet2.0/OutputUnit.cc index bdb9f9a71..2270feaf3 100644 --- a/src/mem/ruby/network/garnet2.0/OutputUnit.cc +++ b/src/mem/ruby/network/garnet2.0/OutputUnit.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 @@ -30,35 +31,23 @@ #include "mem/ruby/network/garnet2.0/OutputUnit.hh" -#include "base/stl_helpers.hh" #include "debug/RubyNetwork.hh" #include "mem/ruby/network/garnet2.0/Credit.hh" +#include "mem/ruby/network/garnet2.0/CreditLink.hh" #include "mem/ruby/network/garnet2.0/Router.hh" - -using namespace std; -using m5::stl_helpers::deletePointers; +#include "mem/ruby/network/garnet2.0/flitBuffer.hh" OutputUnit::OutputUnit(int id, PortDirection direction, Router *router) - : Consumer(router) + : Consumer(router), m_router(router), m_id(id), m_direction(direction), + m_vc_per_vnet(m_router->get_vc_per_vnet()) { - m_id = id; - m_direction = direction; - m_router = router; - m_num_vcs = m_router->get_num_vcs(); - m_vc_per_vnet = m_router->get_vc_per_vnet(); - m_out_buffer = new flitBuffer(); - + const int m_num_vcs = m_router->get_num_vcs(); + outVcState.reserve(m_num_vcs); for (int i = 0; i < m_num_vcs; i++) { - m_outvc_state.push_back(new OutVcState(i, m_router->get_net_ptr())); + outVcState.emplace_back(i, m_router->get_net_ptr()); } } -OutputUnit::~OutputUnit() -{ - delete m_out_buffer; - deletePointers(m_outvc_state); -} - void OutputUnit::decrement_credit(int out_vc) { @@ -66,7 +55,7 @@ OutputUnit::decrement_credit(int out_vc) "outvc %d at time: %lld\n", m_router->get_id(), m_id, out_vc, m_router->curCycle()); - m_outvc_state[out_vc]->decrement_credit(); + outVcState[out_vc].decrement_credit(); } void @@ -76,7 +65,7 @@ OutputUnit::increment_credit(int out_vc) "outvc %d at time: %lld\n", m_router->get_id(), m_id, out_vc, m_router->curCycle()); - m_outvc_state[out_vc]->increment_credit(); + outVcState[out_vc].increment_credit(); } // Check if the output VC (i.e., input VC at next router) @@ -85,8 +74,8 @@ OutputUnit::increment_credit(int out_vc) bool OutputUnit::has_credit(int out_vc) { - assert(m_outvc_state[out_vc]->isInState(ACTIVE_, m_router->curCycle())); - return m_outvc_state[out_vc]->has_credit(); + assert(outVcState[out_vc].isInState(ACTIVE_, m_router->curCycle())); + return outVcState[out_vc].has_credit(); } @@ -110,7 +99,7 @@ OutputUnit::select_free_vc(int vnet) int vc_base = vnet*m_vc_per_vnet; for (int vc = vc_base; vc < vc_base + m_vc_per_vnet; vc++) { if (is_vc_idle(vc, m_router->curCycle())) { - m_outvc_state[vc]->setState(ACTIVE_, m_router->curCycle()); + outVcState[vc].setState(ACTIVE_, m_router->curCycle()); return vc; } } @@ -143,7 +132,7 @@ OutputUnit::wakeup() flitBuffer* OutputUnit::getOutQueue() { - return m_out_buffer; + return &outBuffer; } void @@ -158,8 +147,15 @@ OutputUnit::set_credit_link(CreditLink *credit_link) m_credit_link = credit_link; } +void +OutputUnit::insert_flit(flit *t_flit) +{ + outBuffer.insert(t_flit); + m_out_link->scheduleEventAbsolute(m_router->clockEdge(Cycles(1))); +} + uint32_t OutputUnit::functionalWrite(Packet *pkt) { - return m_out_buffer->functionalWrite(pkt); + return outBuffer.functionalWrite(pkt); } diff --git a/src/mem/ruby/network/garnet2.0/OutputUnit.hh b/src/mem/ruby/network/garnet2.0/OutputUnit.hh index a10539cf9..c720888c1 100644 --- a/src/mem/ruby/network/garnet2.0/OutputUnit.hh +++ b/src/mem/ruby/network/garnet2.0/OutputUnit.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 @@ -36,17 +37,17 @@ #include "mem/ruby/common/Consumer.hh" #include "mem/ruby/network/garnet2.0/CommonTypes.hh" -#include "mem/ruby/network/garnet2.0/CreditLink.hh" #include "mem/ruby/network/garnet2.0/NetworkLink.hh" #include "mem/ruby/network/garnet2.0/OutVcState.hh" -#include "mem/ruby/network/garnet2.0/Router.hh" -#include "mem/ruby/network/garnet2.0/flitBuffer.hh" + +class CreditLink; +class Router; class OutputUnit : public Consumer { public: OutputUnit(int id, PortDirection direction, Router *router); - ~OutputUnit(); + ~OutputUnit() = default; void set_out_link(NetworkLink *link); void set_credit_link(CreditLink *credit_link); void wakeup(); @@ -63,7 +64,7 @@ class OutputUnit : public Consumer int get_credit_count(int vc) { - return m_outvc_state[vc]->get_credit_count(); + return outVcState[vc].get_credit_count(); } inline int @@ -75,36 +76,31 @@ class OutputUnit : public Consumer inline void set_vc_state(VC_state_type state, int vc, Cycles curTime) { - m_outvc_state[vc]->setState(state, curTime); + outVcState[vc].setState(state, curTime); } inline bool is_vc_idle(int vc, Cycles curTime) { - return (m_outvc_state[vc]->isInState(IDLE_, curTime)); + return (outVcState[vc].isInState(IDLE_, curTime)); } - inline void - insert_flit(flit *t_flit) - { - m_out_buffer->insert(t_flit); - m_out_link->scheduleEventAbsolute(m_router->clockEdge(Cycles(1))); - } + void insert_flit(flit *t_flit); uint32_t functionalWrite(Packet *pkt); private: + Router *m_router; int m_id; PortDirection m_direction; - int m_num_vcs; int m_vc_per_vnet; - Router *m_router; NetworkLink *m_out_link; CreditLink *m_credit_link; - flitBuffer *m_out_buffer; // This is for the network link to consume - std::vector m_outvc_state; // vc state of downstream router - + // This is for the network link to consume + flitBuffer outBuffer; + // vc state of downstream router + std::vector outVcState; }; #endif // __MEM_RUBY_NETWORK_GARNET2_0_OUTPUTUNIT_HH__ -- 2.30.2