mem-garnet: Use static allocation in NetworkLink
Use static allocation to manage NetworkLink's pointers. Change-Id: I3ab22b1f912f0119448f9013fd0dfff9bf5a6999 Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24252 Reviewed-by: Srikant Bharadwaj <srikant.bharadwaj@amd.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Daniel Carvalho
parent
5fce5056fd
commit
c2ae0ba0c4
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<unsigned int> & 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user