mem: Replace EventWrapper use with EventFunctionWrapper

NOTE: With this change there is a possibility for `DRAMCtrl::Rank`s
event names to not properly match the rank they were generated by. This
could occur if the public rank member is modified after the Rank's
construction. A patch would mean refactoring Rank and `DRAMCtrl`b to
privatize many of the members of Rank behind getters.

Change-Id: I7b8bd15086f4ffdfd3f40be4aeddac5e786fd78e
Signed-off-by: Sean Wilson <spwilson2@wisc.edu>
Reviewed-on: https://gem5-review.googlesource.com/3745
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
This commit is contained in:
Sean Wilson
2017-06-07 15:02:52 -05:00
parent d0b4774751
commit 8421362cc2
18 changed files with 45 additions and 46 deletions

View File

@@ -61,8 +61,8 @@ Bridge::BridgeSlavePort::BridgeSlavePort(const std::string& _name,
std::vector<AddrRange> _ranges)
: SlavePort(_name, &_bridge), bridge(_bridge), masterPort(_masterPort),
delay(_delay), ranges(_ranges.begin(), _ranges.end()),
outstandingResponses(0), retryReq(false),
respQueueLimit(_resp_limit), sendEvent(*this)
outstandingResponses(0), retryReq(false), respQueueLimit(_resp_limit),
sendEvent([this]{ trySendTiming(); }, _name)
{
}
@@ -71,7 +71,8 @@ Bridge::BridgeMasterPort::BridgeMasterPort(const std::string& _name,
BridgeSlavePort& _slavePort,
Cycles _delay, int _req_limit)
: MasterPort(_name, &_bridge), bridge(_bridge), slavePort(_slavePort),
delay(_delay), reqQueueLimit(_req_limit), sendEvent(*this)
delay(_delay), reqQueueLimit(_req_limit),
sendEvent([this]{ trySendTiming(); }, _name)
{
}

View File

@@ -156,8 +156,7 @@ class Bridge : public MemObject
void trySendTiming();
/** Send event for the response queue. */
EventWrapper<BridgeSlavePort,
&BridgeSlavePort::trySendTiming> sendEvent;
EventFunctionWrapper sendEvent;
public:
@@ -255,8 +254,7 @@ class Bridge : public MemObject
void trySendTiming();
/** Send event for the request queue. */
EventWrapper<BridgeMasterPort,
&BridgeMasterPort::trySendTiming> sendEvent;
EventFunctionWrapper sendEvent;
public:

View File

@@ -62,7 +62,8 @@ BaseCache::CacheSlavePort::CacheSlavePort(const std::string &_name,
BaseCache *_cache,
const std::string &_label)
: QueuedSlavePort(_name, _cache, queue), queue(*_cache, *this, _label),
blocked(false), mustSendRetry(false), sendRetryEvent(this)
blocked(false), mustSendRetry(false),
sendRetryEvent([this]{ processSendRetry(); }, _name)
{
}

View File

@@ -177,8 +177,7 @@ class BaseCache : public MemObject
void processSendRetry();
EventWrapper<CacheSlavePort,
&CacheSlavePort::processSendRetry> sendRetryEvent;
EventFunctionWrapper sendRetryEvent;
};

View File

@@ -73,7 +73,8 @@ Cache::Cache(const CacheParams *p)
clusivity(p->clusivity),
writebackClean(p->writeback_clean),
tempBlockWriteback(nullptr),
writebackTempBlockAtomicEvent(this, false,
writebackTempBlockAtomicEvent([this]{ writebackTempBlockAtomic(); },
name(), false,
EventBase::Delayed_Writeback_Pri)
{
tempBlock = new CacheBlk();

View File

@@ -257,8 +257,7 @@ class Cache : public BaseCache
* finishes. To avoid other calls to recvAtomic getting in
* between, we create this event with a higher priority.
*/
EventWrapper<Cache, &Cache::writebackTempBlockAtomic> \
writebackTempBlockAtomicEvent;
EventFunctionWrapper writebackTempBlockAtomicEvent;
/**
* Store the outstanding requests that we are expecting snoop

View File

@@ -52,7 +52,7 @@ CommMonitor::CommMonitor(Params* params)
: MemObject(params),
masterPort(name() + "-master", *this),
slavePort(name() + "-slave", *this),
samplePeriodicEvent(this),
samplePeriodicEvent([this]{ samplePeriodic(); }, name()),
samplePeriodTicks(params->sample_period),
samplePeriod(params->sample_period / SimClock::Float::s),
stats(params)

View File

@@ -410,7 +410,7 @@ class CommMonitor : public MemObject
void samplePeriodic();
/** Periodic event called at the end of each simulation time bin */
EventWrapper<CommMonitor, &CommMonitor::samplePeriodic> samplePeriodicEvent;
EventFunctionWrapper samplePeriodicEvent;
/**
*@{

View File

@@ -63,7 +63,8 @@ DRAMCtrl::DRAMCtrl(const DRAMCtrlParams* p) :
retryRdReq(false), retryWrReq(false),
busState(READ),
busStateNext(READ),
nextReqEvent(this), respondEvent(this),
nextReqEvent([this]{ processNextReqEvent(); }, name()),
respondEvent([this]{ processRespondEvent(); }, name()),
deviceSize(p->device_size),
deviceBusWidth(p->device_bus_width), burstLength(p->burst_length),
deviceRowBufferSize(p->device_rowbuffer_size),
@@ -1610,8 +1611,12 @@ DRAMCtrl::Rank::Rank(DRAMCtrl& _memory, const DRAMCtrlParams* _p, int rank)
readEntries(0), writeEntries(0), outstandingEvents(0),
wakeUpAllowedAt(0), power(_p, false), banks(_p->banks_per_rank),
numBanksActive(0), actTicks(_p->activation_limit, 0),
writeDoneEvent(*this), activateEvent(*this), prechargeEvent(*this),
refreshEvent(*this), powerEvent(*this), wakeUpEvent(*this)
writeDoneEvent([this]{ processWriteDoneEvent(); }, name()),
activateEvent([this]{ processActivateEvent(); }, name()),
prechargeEvent([this]{ processPrechargeEvent(); }, name()),
refreshEvent([this]{ processRefreshEvent(); }, name()),
powerEvent([this]{ processPowerEvent(); }, name()),
wakeUpEvent([this]{ processWakeUpEvent(); }, name())
{
for (int b = 0; b < _p->banks_per_rank; b++) {
banks[b].bank = b;

View File

@@ -556,28 +556,22 @@ class DRAMCtrl : public AbstractMemory
void scheduleWakeUpEvent(Tick exit_delay);
void processWriteDoneEvent();
EventWrapper<Rank, &Rank::processWriteDoneEvent>
writeDoneEvent;
EventFunctionWrapper writeDoneEvent;
void processActivateEvent();
EventWrapper<Rank, &Rank::processActivateEvent>
activateEvent;
EventFunctionWrapper activateEvent;
void processPrechargeEvent();
EventWrapper<Rank, &Rank::processPrechargeEvent>
prechargeEvent;
EventFunctionWrapper prechargeEvent;
void processRefreshEvent();
EventWrapper<Rank, &Rank::processRefreshEvent>
refreshEvent;
EventFunctionWrapper refreshEvent;
void processPowerEvent();
EventWrapper<Rank, &Rank::processPowerEvent>
powerEvent;
EventFunctionWrapper powerEvent;
void processWakeUpEvent();
EventWrapper<Rank, &Rank::processWakeUpEvent>
wakeUpEvent;
EventFunctionWrapper wakeUpEvent;
};
@@ -685,10 +679,10 @@ class DRAMCtrl : public AbstractMemory
* in these methods
*/
void processNextReqEvent();
EventWrapper<DRAMCtrl,&DRAMCtrl::processNextReqEvent> nextReqEvent;
EventFunctionWrapper nextReqEvent;
void processRespondEvent();
EventWrapper<DRAMCtrl, &DRAMCtrl::processRespondEvent> respondEvent;
EventFunctionWrapper respondEvent;
/**
* Check if the read queue has room for more entries

View File

@@ -53,7 +53,8 @@ DRAMSim2::DRAMSim2(const Params* p) :
p->traceFile, p->range.size() / 1024 / 1024, p->enableDebug),
retryReq(false), retryResp(false), startTick(0),
nbrOutstandingReads(0), nbrOutstandingWrites(0),
sendResponseEvent(this), tickEvent(this)
sendResponseEvent([this]{ sendResponse(); }, name()),
tickEvent([this]{ tick(); }, name())
{
DPRINTF(DRAMSim2,
"Instantiated DRAMSim2 with clock %d ns and queue size %d\n",

View File

@@ -148,7 +148,7 @@ class DRAMSim2 : public AbstractMemory
/**
* Event to schedule sending of responses
*/
EventWrapper<DRAMSim2, &DRAMSim2::sendResponse> sendResponseEvent;
EventFunctionWrapper sendResponseEvent;
/**
* Progress the controller one clock cycle.
@@ -158,7 +158,7 @@ class DRAMSim2 : public AbstractMemory
/**
* Event to schedule clock ticks
*/
EventWrapper<DRAMSim2, &DRAMSim2::tick> tickEvent;
EventFunctionWrapper tickEvent;
/**
* Upstream caches need this packet until true is returned, so

View File

@@ -66,7 +66,8 @@ SerialLink::SerialLinkSlavePort::SerialLinkSlavePort(const std::string& _name,
masterPort(_masterPort), delay(_delay),
ranges(_ranges.begin(), _ranges.end()),
outstandingResponses(0), retryReq(false),
respQueueLimit(_resp_limit), sendEvent(*this)
respQueueLimit(_resp_limit),
sendEvent([this]{ trySendTiming(); }, _name)
{
}
@@ -76,7 +77,7 @@ SerialLink::SerialLinkMasterPort::SerialLinkMasterPort(const std::string&
Cycles _delay, int _req_limit)
: MasterPort(_name, &_serial_link), serial_link(_serial_link),
slavePort(_slavePort), delay(_delay), reqQueueLimit(_req_limit),
sendEvent(*this)
sendEvent([this]{ trySendTiming(); }, _name)
{
}

View File

@@ -146,8 +146,7 @@ class SerialLink : public MemObject
void trySendTiming();
/** Send event for the response queue. */
EventWrapper<SerialLinkSlavePort,
&SerialLinkSlavePort::trySendTiming> sendEvent;
EventFunctionWrapper sendEvent;
public:
@@ -247,8 +246,7 @@ class SerialLink : public MemObject
void trySendTiming();
/** Send event for the request queue. */
EventWrapper<SerialLinkMasterPort,
&SerialLinkMasterPort::trySendTiming> sendEvent;
EventFunctionWrapper sendEvent;
public:

View File

@@ -55,7 +55,8 @@ SimpleMemory::SimpleMemory(const SimpleMemoryParams* p) :
port(name() + ".port", *this), latency(p->latency),
latency_var(p->latency_var), bandwidth(p->bandwidth), isBusy(false),
retryReq(false), retryResp(false),
releaseEvent(this), dequeueEvent(this)
releaseEvent([this]{ release(); }, name()),
dequeueEvent([this]{ dequeue(); }, name())
{
}

View File

@@ -158,7 +158,7 @@ class SimpleMemory : public AbstractMemory
*/
void release();
EventWrapper<SimpleMemory, &SimpleMemory::release> releaseEvent;
EventFunctionWrapper releaseEvent;
/**
* Dequeue a packet from our internal packet queue and move it to
@@ -166,7 +166,7 @@ class SimpleMemory : public AbstractMemory
*/
void dequeue();
EventWrapper<SimpleMemory, &SimpleMemory::dequeue> dequeueEvent;
EventFunctionWrapper dequeueEvent;
/**
* Detemine the latency.

View File

@@ -147,7 +147,7 @@ template <typename SrcType, typename DstType>
BaseXBar::Layer<SrcType,DstType>::Layer(DstType& _port, BaseXBar& _xbar,
const std::string& _name) :
port(_port), xbar(_xbar), _name(_name), state(IDLE),
waitingForPeer(NULL), releaseEvent(this)
waitingForPeer(NULL), releaseEvent([this]{ releaseLayer(); }, name())
{
}

View File

@@ -237,7 +237,7 @@ class BaseXBar : public MemObject
void releaseLayer();
/** event used to schedule a release of the layer */
EventWrapper<Layer, &Layer::releaseLayer> releaseEvent;
EventFunctionWrapper releaseEvent;
/**
* Stats for occupancy and utilization. These stats capture