77 #ifndef __DEV_DIST_IFACE_HH__
78 #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);
bool run(bool same_tick) override
Core method to perform a full dist sync.
void pushPacket(EthPacketPtr new_packet, Tick send_tick, Tick send_delay)
Push a newly arrived packet into the desc queue.
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 start()
Schedule the first periodic sync event.
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.
DrainState
Object drain/handover states.
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.
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.
bool run(bool same_tick) override
Core method to perform a full dist sync.
void serialize(CheckpointOut &cp) const override
Serialize an object.
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 resumeRecvTicks()
Adjust receive ticks for pending packets when restoring from a checkpoint.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void drainResume() override
Resume execution after a successful drain.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void serialize(CheckpointOut &cp) const override
Serialize an object.
bool _draining
Flag to set when the system is draining.
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.
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...
void serialize(CheckpointOut &cp) const override
Serialize an object.
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
void init(const Event *e, Tick link_delay)
uint64_t Tick
Tick count type.
Tick calcReceiveTick(Tick send_tick, Tick send_delay, Tick prev_recv_tick)
Calculate the tick to schedule the next receive done event.
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.
void init(Event *recv_done, Tick link_delay)
Initialize network link parameters.
static const Priority Sim_Exit_Pri
If we want to exit on this cycle, it's the very last thing we do.
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.
void requestExit(ReqType req) override
void unserialize(CheckpointIn &cp) override
Unserialize an object.
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.
void process() override
This is a global event so process() will only be called by exactly one simulation thread...
DistHeaderPkt::ReqType ReqType
ReqType needStopSync
Sync stop requested.
ReqType needExit
Exit requested.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void requestStopSync(ReqType req) override
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.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
virtual void requestStopSync(ReqType req)=0
void requestCkpt(ReqType req) override
void serialize(CheckpointOut &cp) const override
Serialize an object.
void serialize(CheckpointOut &cp) const override
Serialize an object.
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.
SyncSwitch(int num_nodes)
unsigned rank
The rank of this process among the gem5 peers.