From c2ae0ba0c4377f56b82c24ce7e2b7e432605e27d Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Thu, 9 Jan 2020 22:28:27 +0100 Subject: [PATCH] mem-garnet: Use static allocation in NetworkLink Use static allocation to manage NetworkLink's pointers. Change-Id: I3ab22b1f912f0119448f9013fd0dfff9bf5a6999 Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24252 Reviewed-by: Srikant Bharadwaj Maintainer: Nikos Nikoleris Tested-by: kokoro --- src/mem/ruby/network/garnet2.0/NetworkLink.cc | 19 ++++++++----------- src/mem/ruby/network/garnet2.0/NetworkLink.hh | 16 ++++++++-------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/mem/ruby/network/garnet2.0/NetworkLink.cc b/src/mem/ruby/network/garnet2.0/NetworkLink.cc index c8460d290..d4bccd828 100644 --- a/src/mem/ruby/network/garnet2.0/NetworkLink.cc +++ b/src/mem/ruby/network/garnet2.0/NetworkLink.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 @@ -36,17 +37,12 @@ NetworkLink::NetworkLink(const Params *p) : ClockedObject(p), Consumer(this), m_id(p->link_id), m_type(NUM_LINK_TYPES_), m_latency(p->link_latency), - linkBuffer(new flitBuffer()), link_consumer(nullptr), + linkBuffer(), link_consumer(nullptr), link_srcQueue(nullptr), m_link_utilized(0), m_vc_load(p->vcs_per_vnet * p->virt_nets) { } -NetworkLink::~NetworkLink() -{ - delete linkBuffer; -} - void NetworkLink::setLinkConsumer(Consumer *consumer) { @@ -54,18 +50,19 @@ NetworkLink::setLinkConsumer(Consumer *consumer) } void -NetworkLink::setSourceQueue(flitBuffer *srcQueue) +NetworkLink::setSourceQueue(flitBuffer* src_queue) { - link_srcQueue = srcQueue; + link_srcQueue = src_queue; } void NetworkLink::wakeup() { + assert(link_srcQueue != nullptr); if (link_srcQueue->isReady(curCycle())) { flit *t_flit = link_srcQueue->getTopFlit(); t_flit->set_time(curCycle() + m_latency); - linkBuffer->insert(t_flit); + linkBuffer.insert(t_flit); link_consumer->scheduleEventAbsolute(clockEdge(m_latency)); m_link_utilized++; m_vc_load[t_flit->get_vc()]++; @@ -97,5 +94,5 @@ CreditLinkParams::create() uint32_t NetworkLink::functionalWrite(Packet *pkt) { - return linkBuffer->functionalWrite(pkt); + return linkBuffer.functionalWrite(pkt); } diff --git a/src/mem/ruby/network/garnet2.0/NetworkLink.hh b/src/mem/ruby/network/garnet2.0/NetworkLink.hh index 23d15d9e6..bc3d73a79 100644 --- a/src/mem/ruby/network/garnet2.0/NetworkLink.hh +++ b/src/mem/ruby/network/garnet2.0/NetworkLink.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 @@ -47,10 +48,10 @@ class NetworkLink : public ClockedObject, public Consumer public: typedef NetworkLinkParams Params; NetworkLink(const Params *p); - ~NetworkLink(); + ~NetworkLink() = default; void setLinkConsumer(Consumer *consumer); - void setSourceQueue(flitBuffer *srcQueue); + void setSourceQueue(flitBuffer *src_queue); void setType(link_type type) { m_type = type; } link_type getType() { return m_type; } void print(std::ostream& out) const {} @@ -60,11 +61,10 @@ class NetworkLink : public ClockedObject, public Consumer unsigned int getLinkUtilization() const { return m_link_utilized; } const std::vector & getVcLoad() const { return m_vc_load; } - inline bool isReady(Cycles curTime) - { return linkBuffer->isReady(curTime); } + inline bool isReady(Cycles curTime) { return linkBuffer.isReady(curTime); } - inline flit* peekLink() { return linkBuffer->peekTopFlit(); } - inline flit* consumeLink() { return linkBuffer->getTopFlit(); } + inline flit* peekLink() { return linkBuffer.peekTopFlit(); } + inline flit* consumeLink() { return linkBuffer.getTopFlit(); } uint32_t functionalWrite(Packet *); void resetStats(); @@ -74,7 +74,7 @@ class NetworkLink : public ClockedObject, public Consumer link_type m_type; const Cycles m_latency; - flitBuffer *linkBuffer; + flitBuffer linkBuffer; Consumer *link_consumer; flitBuffer *link_srcQueue; -- 2.30.2