ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
gvt.h
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include <core/core.h>
12 #include <lp/msg.h>
13 
14 extern void gvt_global_init(void);
15 extern simtime_t gvt_phase_run(void);
16 extern void gvt_on_msg_extraction(simtime_t msg_t);
17 
18 extern __thread _Bool gvt_phase;
19 extern __thread uint32_t remote_msg_seq[2][MAX_NODES];
20 extern __thread uint32_t remote_msg_received[2];
21 
22 extern void gvt_start_processing(void);
23 extern void gvt_on_done_ctrl_msg(void);
24 extern void gvt_msg_drain(void);
25 
26 static inline void gvt_remote_msg_send(struct lp_msg *msg, nid_t dest_nid)
27 {
28  msg->m_seq = (remote_msg_seq[gvt_phase][dest_nid]++ << 1) | gvt_phase;
29  msg->raw_flags = (nid << (MAX_THREADS_EXP + 2)) | ((rid + 1) << 2) | gvt_phase;
30 }
31 
32 static inline void gvt_remote_anti_msg_send(struct lp_msg *msg, nid_t dest_nid)
33 {
34  ++remote_msg_seq[gvt_phase][dest_nid];
35  msg->raw_flags |= gvt_phase << 1U;
36 }
37 
38 static inline void gvt_remote_msg_receive(struct lp_msg *msg)
39 {
40  ++remote_msg_received[msg->raw_flags & 1U];
41  msg->raw_flags &= ~((uint32_t)3U);
42 }
43 
44 static inline void gvt_remote_anti_msg_receive(struct lp_msg *msg)
45 {
46  ++remote_msg_received[(msg->raw_flags >> 1U) & 1U];
47  msg->raw_flags &= ~((uint32_t)3U);
48  msg->raw_flags |= MSG_FLAG_ANTI;
49 }
double simtime_t
Simulation time data type.
Definition: ROOT-Sim.h:27
__thread rid_t rid
The identifier of the thread.
Definition: core.c:13
nid_t nid
The node identifier of the node.
Definition: core.c:15
Core ROOT-Sim functionalities.
#define MAX_THREADS_EXP
The maximum number of supported threads.
Definition: core.h:65
int nid_t
Used to identify MPI nodes in a distributed environment.
Definition: core.h:72
#define MAX_NODES
The maximum number of supported MPI nodes.
Definition: core.h:62
void gvt_remote_anti_msg_send(struct lp_msg *msg, nid_t dest_nid)
void gvt_remote_anti_msg_receive(struct lp_msg *msg)
void gvt_remote_msg_send(struct lp_msg *msg, nid_t dest_nid)
void gvt_remote_msg_receive(struct lp_msg *msg)
void gvt_start_processing(void)
Handles a MSG_CTRL_GVT_START control message.
Definition: gvt.c:70
void gvt_on_msg_extraction(simtime_t msg_t)
Informs the GVT subsystem that a new message is being processed.
Definition: gvt.c:92
simtime_t gvt_phase_run(void)
Executes a step of the GVT algorithm.
Definition: gvt.c:254
void gvt_on_done_ctrl_msg(void)
Handles a MSG_CTRL_GVT_DONE control message.
Definition: gvt.c:81
void gvt_msg_drain(void)
Cleanup the distributed state of the GVT algorithm.
Definition: gvt.c:275
void gvt_global_init(void)
Initializes the gvt module in the node.
Definition: gvt.c:59
Message management functions.
A model simulation message.
Definition: msg.h:59
uint32_t raw_flags
The message unique id, used for inter-node anti messages.
Definition: msg.h:70
uint32_t m_seq
The message sequence number.
Definition: msg.h:79