75#ifndef __DEV_DIST_IFACE_HH__
76#define __DEV_DIST_IFACE_HH__
130 std::condition_variable
cv;
177 virtual bool run(
bool same_tick) = 0;
225 bool run(
bool same_tick)
override;
230 ReqType do_stop_sync)
override;
264 bool run(
bool same_tick)
override;
269 ReqType do_stop_sync)
override;
272 panic(
"Switch requested checkpoint");
275 panic(
"Switch requested exit");
278 panic(
"Switch requested stop sync");
403 Tick prev_recv_tick);
Class to encapsulate information about data packets received.
Tick prevRecvTick
The tick when the most recent receive event was processed.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
bool ckptRestore
Flag to set if receive ticks for pending packets need to be recalculated due to changed link latencie...
std::queue< Desc > descQueue
The queue to store the receive descriptors.
Tick linkDelay
The link delay in ticks for the simulated Ethernet link.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void resumeRecvTicks()
Adjust receive ticks for pending packets when restoring from a checkpoint.
RecvScheduler(EventManager *em)
Scheduler for the incoming data packets.
EthPacketPtr popPacket()
Fetch the next packet that is to be received by the simulated network link.
void pushPacket(EthPacketPtr new_packet, Tick send_tick, Tick send_delay)
Push a newly arrived packet into the desc queue.
Tick calcReceiveTick(Tick send_tick, Tick send_delay, Tick prev_recv_tick)
Calculate the tick to schedule the next receive done event.
EventManager * eventManager
The event manager associated with the simulated Ethernet link.
Event * recvDone
The receive done event for the simulated Ethernet link.
The global event to schedule periodic dist sync.
bool _draining
Flag to set when the system is draining.
void start()
Schedule the first periodic sync event.
SyncEvent()
Only the firstly instantiated DistIface object will call this constructor.
void process() override
This is a global event so process() will only be called by exactly one simulation thread.
void requestExit(ReqType req) override
void serialize(CheckpointOut &cp) const override
Serialize an object.
ReqType needStopSync
Sync stop requested.
bool progress(Tick max_req_tick, Tick next_repeat, ReqType do_ckpt, ReqType do_exit, ReqType do_stop_sync) override
Callback when the receiver thread gets a sync ack message.
void requestCkpt(ReqType req) override
bool run(bool same_tick) override
Core method to perform a full dist sync.
ReqType needCkpt
Ckpt requested.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void requestStopSync(ReqType req) override
ReqType needExit
Exit requested.
bool run(bool same_tick) override
Core method to perform a full dist sync.
SyncSwitch(int num_nodes)
unsigned numExitReq
Counter for recording exit requests.
void requestExit(ReqType) override
void requestStopSync(ReqType) override
void serialize(CheckpointOut &cp) const override
Serialize an object.
void requestCkpt(ReqType) override
void unserialize(CheckpointIn &cp) override
Unserialize an object.
unsigned numCkptReq
Counter for recording ckpt requests.
bool progress(Tick max_req_tick, Tick next_repeat, ReqType do_ckpt, ReqType do_exit, ReqType do_stop_sync) override
Callback when the receiver thread gets a sync ack message.
unsigned numStopSyncReq
Counter for recording stop sync requests.
unsigned numNodes
Number of connected simulated nodes.
This class implements global sync operations among gem5 peer processes.
bool isAbort
Flag is set if the sync is aborted (e.g.
Tick nextRepeat
The repeat value for the next periodic sync.
bool doStopSync
Flag is set if sync is to stop upon sync completion.
unsigned waitNum
Number of receiver threads that not yet completed the current global synchronisation.
Tick nextAt
Tick for the next periodic sync (if the event is not scheduled yet)
bool doExit
Flag is set if exit is permitted upon sync completion.
virtual void requestStopSync(ReqType req)=0
virtual bool run(bool same_tick)=0
Core method to perform a full dist sync.
virtual void requestExit(ReqType req)=0
virtual void requestCkpt(ReqType req)=0
std::mutex lock
The lock to protect access to the Sync object.
std::condition_variable cv
Condition variable for the simulation thread to wait on until all receiver threads completes the curr...
virtual bool progress(Tick send_tick, Tick next_repeat, ReqType do_ckpt, ReqType do_exit, ReqType do_stop_sync)=0
Callback when the receiver thread gets a sync ack message.
virtual void serialize(CheckpointOut &cp) const override=0
Serialize an object.
void abort()
Abort processing an on-going sync event (in case of an error, e.g.
bool doCkpt
Flag is set if taking a ckpt is permitted upon sync completion.
virtual void unserialize(CheckpointIn &cp) override=0
Unserialize an object.
The interface class to talk to peer gem5 processes.
static uint64_t rankParam()
Getter for the dist rank param.
virtual void initTransport()=0
Init hook for the underlaying transport.
RecvScheduler recvScheduler
Meta information about data packets received.
static bool readyToExit(Tick delay)
Initiate the exit from the simulation.
bool syncStartOnPseudoOp
Use pseudoOp to start synchronization.
static void toggleSync(ThreadContext *tc)
Trigger the primary to start/stop synchronization.
static bool readyToCkpt(Tick delay, Tick period)
Initiate taking a checkpoint.
unsigned rank
The rank of this process among the gem5 peers.
unsigned distIfaceId
Unique id for the dist link.
static DistIface * primary
The very first DistIface object created becomes the primary interface.
DistHeaderPkt::MsgType MsgType
static uint64_t sizeParam()
Getter for the dist size param.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
std::thread * recvThread
Receiver thread pointer.
static SyncEvent * syncEvent
The singleton SyncEvent object to schedule periodic dist sync.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
static System * sys
System pointer used to wakeup sleeping threads when stopping sync.
EthPacketPtr packetIn()
Fetch the packet scheduled to be received next by the simulated network link.
void recvThreadFunc(Event *recv_done, Tick link_delay)
The function executed by a receiver thread.
virtual void sendCmd(const Header &header)=0
Send out a control command to the remote end.
virtual bool recvHeader(Header &header)=0
Receive a header (i.e.
static Sync * sync
The singleton Sync object to perform dist synchronisation.
virtual void sendPacket(const Header &header, const EthPacketPtr &packet)=0
Send out a data packet to the remote end.
static unsigned distIfaceNum
Number of DistIface objects (i.e.
void drainResume() override
Resume execution after a successful drain.
void spawnRecvThread(const Event *recv_done, Tick link_delay)
spawn the receiver thread.
static bool isSwitch
Is this node a switch?
void serialize(CheckpointOut &cp) const override
Serialize an object.
virtual void recvPacket(const Header &header, EthPacketPtr &packet)=0
Receive a packet from the remote end.
Tick syncRepeat
Frequency of dist sync events in ticks.
Tick syncStart
Tick to schedule the first dist sync event.
DistHeaderPkt::Header Header
static unsigned recvThreadsNum
Number of receiver threads (in this gem5 process)
DistIface(unsigned dist_rank, unsigned dist_size, Tick sync_start, Tick sync_repeat, EventManager *em, bool use_pseudo_op, bool is_switch, int num_nodes)
ctor
void packetOut(EthPacketPtr pkt, Tick send_delay)
Send out an Ethernet packet.
unsigned size
The number of gem5 processes comprising this dist simulation.
DistHeaderPkt::ReqType ReqType
Interface for objects that might require draining before checkpointing.
A special global event that synchronizes all threads and forces them to process asynchronously enqueu...
Basic support for object serialization.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Global events and related declarations.
DrainState
Object drain/handover states.
static const Priority Sim_Exit_Pri
If we want to exit on this cycle, it's the very last thing we do.
#define panic(...)
This implements a cprintf based panic() function.
const FlagsType init
This Stat is Initialized.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::ostream CheckpointOut
uint64_t Tick
Tick count type.
std::shared_ptr< EthPacketData > EthPacketPtr
Received packet descriptor.
Desc(EthPacketPtr p, Tick s, Tick d)
void serialize(CheckpointOut &cp) const override
Serialize an object.
void unserialize(CheckpointIn &cp) override
Unserialize an object.