75 #ifndef __DEV_DIST_IFACE_HH__ 76 #define __DEV_DIST_IFACE_HH__ 128 std::condition_variable
cv;
175 virtual bool run(
bool same_tick) = 0;
186 ReqType do_stop_sync) = 0;
223 bool run(
bool same_tick)
override;
228 ReqType do_stop_sync)
override;
262 bool run(
bool same_tick)
override;
267 ReqType do_stop_sync)
override;
270 panic(
"Switch requested checkpoint");
273 panic(
"Switch requested exit");
276 panic(
"Switch requested stop sync");
319 void process()
override;
345 Desc() : sendTick(0), sendDelay(0) {}
347 packet(p), sendTick(s), sendDelay(d) {}
349 packet(d.packet), sendTick(d.sendTick), sendDelay(d.sendDelay) {}
399 Tick calcReceiveTick(
Tick send_tick,
401 Tick prev_recv_tick);
417 prevRecvTick(0), recvDone(nullptr), linkDelay(0),
418 eventManager(em), ckptRestore(false) {}
450 void resumeRecvTicks();
#define panic(...)
This implements a cprintf based panic() function.
Global events and related declarations.
virtual void sendCmd(const Header &header)=0
Send out a control command to the remote end.
void requestCkpt(ReqType) override
void spawnRecvThread(const Event *recv_done, Tick link_delay)
spawn the receiver thread.
virtual void requestExit(ReqType req)=0
unsigned numNodes
Number of connected simulated nodes.
virtual void sendPacket(const Header &header, const EthPacketPtr &packet)=0
Send out a data packet to the remote end.
DrainState drain() override
Notify an object that it needs to drain its state.
static unsigned recvThreadsNum
Number of receiver threads (in this gem5 process)
bool doCkpt
Flag is set if taking a ckpt is permitted upon sync completion.
Desc(EthPacketPtr p, Tick s, Tick d)
virtual bool recvHeader(Header &header)=0
Receive a header (i.e.
void abort()
Abort processing an on-going sync event (in case of an error, e.g.
A special global event that synchronizes all threads and forces them to process asynchronously enqueu...
bool syncStartOnPseudoOp
Use pseudoOp to start synchronization.
Tick prevRecvTick
The tick when the most recent receive event was processed.
virtual void serialize(CheckpointOut &cp) const override=0
Serialize an object.
EthPacketPtr popPacket()
Fetch the next packet that is to be received by the simulated network link.
static bool isSwitch
Is this node a switch?
void drainResume() override
Resume execution after a successful drain.
bool _draining
Flag to set when the system is draining.
std::thread * recvThread
Receiver thread pointer.
static void toggleSync(ThreadContext *tc)
Trigger the master to start/stop synchronization.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
DrainState
Object drain/handover states.
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 initTransport()=0
Init hook for the underlaying transport.
virtual bool run(bool same_tick)=0
Core method to perform a full dist sync.
Received packet descriptor.
unsigned numExitReq
Counter for recording exit requests.
void requestExit(ReqType) override
static DistIface * master
The very first DistIface object created becomes the master.
Interface for objects that might require draining before checkpointing.
bool ckptRestore
Flag to set if receive ticks for pending packets need to be recalculated due to changed link latencie...
Tick linkDelay
The link delay in ticks for the simulated Ethernet link.
void packetOut(EthPacketPtr pkt, Tick send_delay)
Send out an Ethernet packet.
This class implements global sync operations among gem5 peer processes.
static uint64_t sizeParam()
Getter for the dist size param.
void requestStopSync(ReqType) override
uint64_t Tick
Tick count type.
unsigned waitNum
Number of receiver threads that not yet completed the current global synchronisation.
unsigned numCkptReq
Counter for recording ckpt requests.
Tick nextRepeat
The repeat value for the next periodic sync.
Tick syncStart
Tick to schedule the first dist sync event.
static bool readyToCkpt(Tick delay, Tick period)
Initiate taking a checkpoint.
static SyncEvent * syncEvent
The singleton SyncEvent object to schedule periodic dist sync.
std::shared_ptr< EthPacketData > EthPacketPtr
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
bool doExit
Flag is set if exit is permitted upon sync completion.
static bool readyToExit(Tick delay)
Initiate the exit from the simulation.
SyncEvent()
Only the firstly instantiated DistIface object will call this constructor.
RecvScheduler(EventManager *em)
Scheduler for the incoming data packets.
bool doStopSync
Flag is set if sync is to stop upon sync completion.
The global event to schedule periodic dist sync.
virtual void unserialize(CheckpointIn &cp) override=0
Unserialize an object.
Tick nextAt
Tick for the next periodic sync (if the event is not scheduled yet)
unsigned numStopSyncReq
Counter for recording stop sync requests.
Basic support for object serialization.
unsigned size
The number of gem5 processes comprising this dist simulation.
void recvThreadFunc(Event *recv_done, Tick link_delay)
The function executed by a receiver thread.
std::queue< Desc > descQueue
The queue to store the receive descriptors.
RecvScheduler recvScheduler
Meta information about data packets received.
DistHeaderPkt::ReqType ReqType
ReqType needStopSync
Sync stop requested.
ReqType needExit
Exit requested.
Tick syncRepeat
Frequency of dist sync events in ticks.
static System * sys
System pointer used to wakeup sleeping threads when stopping sync.
DistHeaderPkt::Header Header
std::ostream CheckpointOut
static Sync * sync
The singleton Sync object to perform dist synchronisation.
void init(Tick start, Tick repeat)
Initialize periodic sync params.
unsigned distIfaceId
Unique id for the dist link.
static unsigned distIfaceNum
Number of DistIface objects (i.e.
virtual void recvPacket(const Header &header, EthPacketPtr &packet)=0
Receive a packet from the remote end.
virtual void requestStopSync(ReqType req)=0
std::condition_variable cv
Condition variable for the simulation thread to wait on until all receiver threads completes the curr...
std::mutex lock
The lock to protect access to the Sync object.
EthPacketPtr packetIn()
Fetch the packet scheduled to be received next by the simulated network link.
ReqType needCkpt
Ckpt requested.
DistHeaderPkt::MsgType MsgType
Event * recvDone
The receive done event for the simulated Ethernet link.
virtual void requestCkpt(ReqType req)=0
The interface class to talk to peer gem5 processes.
Class to encapsulate information about data packets received.
static uint64_t rankParam()
Getter for the dist rank param.
EventManager * eventManager
The event manager associated with the simulated Ethernet link.
bool isAbort
Flag is set if the sync is aborted (e.g.
unsigned rank
The rank of this process among the gem5 peers.