51 kphase_white_msg_redux,
74 timer gvt_round_timer;
77 static unsigned int init_kvt_tkn;
78 static unsigned int commit_gvt_tkn;
83 static volatile enum kernel_phases kernel_phase = kphase_idle;
85 static unsigned int init_completed_tkn;
86 static unsigned int commit_kvt_tkn;
87 static unsigned int idle_tkn;
141 local_min_barrier = rsalloc(
sizeof(
simtime_t) * n_cores);
142 for (i = 0; i <
n_cores; i++) {
144 local_min_barrier[i] =
INFTY;
147 timer_start(gvt_timer);
166 }
else if (kernel_phase == kphase_white_msg_redux || kernel_phase == kphase_kvt) {
184 static inline void reduce_local_gvt(
void)
186 foreach_bound_lp(lp) {
199 if (lp->bound->next == NULL)
259 for (i = 0; i <
n_cores; i++) {
270 bool start_new_gvt(
void)
280 return timer_value_milli(gvt_timer) >
306 if (kernel_phase == kphase_idle) {
308 if (start_new_gvt() &&
311 timer_start(gvt_round_timer);
323 ccgs_reduce_termination();
334 init_completed_tkn = 1;
346 kernel_phase = kphase_start;
348 timer_restart(gvt_timer);
355 if (kernel_phase == kphase_start &&
thread_phase == tphase_idle) {
370 if (
iCAS(&init_completed_tkn, 1, 0)) {
373 kernel_phase = kphase_white_msg_redux;
375 kernel_phase = kphase_kvt;
383 if (kernel_phase == kphase_white_msg_redux
385 if (
iCAS(&init_kvt_tkn, 1, 0)) {
387 kernel_phase = kphase_kvt;
395 if (kernel_phase == kphase_kvt &&
thread_phase != tphase_aware) {
398 if (
iCAS(&commit_kvt_tkn, 1, 0)) {
402 kernel_phase = kphase_gvt_redux;
406 kernel_phase = kphase_fossil;
416 if (
iCAS(&commit_gvt_tkn, 1, 0)) {
417 int gvt_round_time = timer_value_micro(gvt_round_timer);
418 statistics_post_data(
current, STAT_GVT_ROUND_TIME, gvt_round_time);
421 kernel_phase = kphase_fossil;
429 if (kernel_phase == kphase_fossil &&
thread_phase == tphase_aware) {
440 statistics_on_gvt(new_gvt);
448 if (
iCAS(&idle_tkn, 1, 0)) {
449 kernel_phase = kphase_idle;
static atomic_t counter_A
How many threads have left phase A?
simtime_t last_reduced_gvt(void)
Return the last GVT value.
void exit_red_phase(void)
Make a thread exit from red phase.
bool all_white_msg_received(void)
Check if white messages are all received.
void process_bottom_halves(void)
#define min(a, b)
Macro to find the minimum among two values.
void join_white_msg_redux(void)
Join the white message reduction collective operation.
void flush_white_msg_recv(void)
Reset received white messages.
bool gvt_redux_completed(void)
Check if final GVT reduction is complete.
#define atomic_read(v)
Read operation on an atomic counter.
Core ROOT-Sim functionalities.
ROOT-Sim header for model development.
unsigned int n_cores
Total number of cores required for simulation.
static __thread enum thread_phases thread_phase
What is my phase? All threads start in the initial phase.
void atomic_dec(atomic_t *)
simtime_t get_last_gvt(void)
static simtime_t * local_min
The local (per-thread) minimum. It's not TLS, rather an array, to allow reduction by master thread...
simtime_t gvt_operations(void)
The ROOT-Sim scheduler main module header.
bool gvt_init_pending(void)
Check if there are pending GVT-init messages around.
Generic thread management facilities.
__thread struct lp_struct * current
This is a per-thread variable pointing to the block state of the LP currently scheduled.
Consistent and Committed Global State.
#define atomic_set(v, i)
Set operation on an atomic counter.
#define INFTY
Infinite timestamp: this is the highest timestamp in a simulation run.
bool white_msg_redux_completed(void)
Test completion of white message reduction collective operation.
double simtime_t
This defines the type with whom timestamps are represented.
simulation_configuration rootsim_config
This global variable holds the configuration for the current simulation.
Memory Manager main header.
simtime_t * min_outgoing_red_msg
Minimum time among all the outgoing red messages for each thread.
void wait_white_msg_redux(void)
Wait for the completion of wait message reduction.
void enter_red_phase(void)
Make a thread enter into red phase.
#define master_thread()
This macro expands to true if the current KLT is the master thread for the local kernel.
bool iCAS(volatile uint32_t *ptr, uint32_t oldVal, uint32_t newVal)
#define D_DIFFER(a, b)
Difference condition for doubles.
static __thread simtime_t last_gvt
#define master_kernel()
This macro expands to true if the local kernel is the master kernel.
static atomic_t counter_B
How many threads have left phase B?
static atomic_t counter_send
How many threads have left phase send?
void broadcast_gvt_init(unsigned int round)
Initiate a distributed GVT.
void receive_remote_msgs(void)
Receive remote messages.
void gvt_init_clear(void)
Forcely extract GVT-init message from MPI.
void flush_white_msg_sent(void)
Reset sent white messages.
void adopt_new_gvt(simtime_t new_gvt)
static volatile unsigned int current_GVT_round
To be used with CAS to determine who is starting the next GVT reduction phase.
__thread unsigned int local_tid
static __thread unsigned int my_GVT_round
Per-thread GVT round counter.
Distributed GVT Support module.
void join_gvt_redux(simtime_t local_vt)
Reduce the GVT value.
int gvt_time_period
Wall-Clock time to wait before executiong GVT operations.
#define unlikely(exp)
Optimize the branch as likely not taken.