The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
gvt.c File Reference

Global Virtual Time. More...

#include <ROOT-Sim.h>
#include <arch/thread.h>
#include <gvt/gvt.h>
#include <gvt/ccgs.h>
#include <core/core.h>
#include <core/init.h>
#include <core/timer.h>
#include <scheduler/process.h>
#include <scheduler/scheduler.h>
#include <statistics/statistics.h>
#include <mm/mm.h>
#include <communication/mpi.h>
#include <communication/gvt.h>
+ Include dependency graph for gvt.c:

Go to the source code of this file.

Enumerations

enum  kernel_phases {
  kphase_start, kphase_white_msg_redux, kphase_kvt, kphase_gvt_redux,
  kphase_fossil, kphase_idle
}
 
enum  thread_phases {
  tphase_A, tphase_send, tphase_B, tphase_aware,
  tphase_idle
}
 

Functions

void gvt_init (void)
 
void gvt_fini (void)
 
simtime_t get_last_gvt (void)
 
static void reduce_local_gvt (void)
 
simtime_t GVT_phases (void)
 
bool start_new_gvt (void)
 
simtime_t gvt_operations (void)
 

Variables

timer gvt_timer
 
timer gvt_round_timer
 
static unsigned int init_kvt_tkn
 
static unsigned int commit_gvt_tkn
 
static enum kernel_phases kernel_phase = kphase_idle
 
static unsigned int init_completed_tkn
 
static unsigned int commit_kvt_tkn
 
static unsigned int idle_tkn
 
static atomic_t counter_initialized
 
static atomic_t counter_kvt
 
static atomic_t counter_finalized
 
static volatile unsigned int current_GVT_round = 0
 To be used with CAS to determine who is starting the next GVT reduction phase.
 
static atomic_t counter_A
 How many threads have left phase A?
 
static atomic_t counter_send
 How many threads have left phase send?
 
static atomic_t counter_B
 How many threads have left phase B?
 
static __thread simtime_t last_gvt = 0.0
 
static volatile simtime_t new_gvt = 0.0
 
static __thread enum thread_phases thread_phase = tphase_idle
 What is my phase? All threads start in the initial phase.
 
static __thread unsigned int my_GVT_round = 0
 Per-thread GVT round counter.
 
static simtime_tlocal_min
 The local (per-thread) minimum. It's not TLS, rather an array, to allow reduction by master thread.
 
static simtime_tlocal_min_barrier
 

Detailed Description

Global Virtual Time.

This module implements the GVT reduction. The current implementation is non blocking for observable simulation plaftorms.

This file is part of ROOT-Sim (ROme OpTimistic Simulator).

ROOT-Sim is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; only version 3 of the License applies.

ROOT-Sim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ROOT-Sim; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Author
Alessandro Pellegrini
Francesco Quaglia
Tommaso Tocci
Date
June 14, 2014

Definition in file gvt.c.

Function Documentation

simtime_t get_last_gvt ( void  )
inline

This function returns the last computed GVT value at each thread. It can be safely used concurrently to keep track of the evolution of the committed trajectory. It's so far mainly used for termination detection based on passed simulation time.

Definition at line 179 of file gvt.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gvt_fini ( void  )

Finalizer of the GVT subsystem.

Definition at line 156 of file gvt.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gvt_init ( void  )

Initialization of the GVT subsystem.

Definition at line 132 of file gvt.c.

+ Here is the caller graph for this function:

simtime_t gvt_operations ( void  )

This is the entry point from the main simulation loop to the GVT subsystem. This function is not executed in case of a serial simulation, and is executed concurrently by different worker threads in case of a parallel one. All the operations here implemented must be re-entrant. Any state variable of the GVT implementation must be declared statically and globally (in case, on a per-thread basis). This function is called at every simulation loop, so at the beginning the code should check whether a GVT computation is occurring, or if a computation must be started.

Returns
The newly computed GVT value, or -1.0. Only a Master Thread should return a value different from -1.0, to avoid generating too much information. If every thread will return a value different from -1.0, nothing will be broken, but all the values will be shown associated with the same kernel id (no way to distinguish between different threads here).

Definition at line 300 of file gvt.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

__thread simtime_t last_gvt = 0.0
static

Keep track of the last computed gvt value. Its a per-thread variable to avoid synchronization on it, but eventually all threads write here the same exact value. The 'adopted_last_gvt' version is used to maintain the adopted gvt value in a temporary variable. It is then copied to last_gvt during the end phase, to avoid possible critical races when checking the termination upon reaching a certain simulation time value.

Definition at line 113 of file gvt.c.