ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
Macros | Functions | Variables
process.c File Reference

LP state management functions. More...

#include <lp/process.h>
#include <arch/timer.h>
#include <datatypes/msg_queue.h>
#include <distributed/mpi.h>
#include <gvt/fossil.h>
#include <gvt/gvt.h>
#include <log/stats.h>
#include <lp/common.h>
#include <lp/lp.h>
#include <mm/auto_ckpt.h>
#include <mm/msg_allocator.h>
#include <serial/serial.h>
Include dependency graph for process.c:

Macros

#define mark_msg_remote(msg_p)   ((struct lp_msg *)(((uintptr_t)(msg_p)) | 2U))
 
#define mark_msg_sent(msg_p)   ((struct lp_msg *)(((uintptr_t)(msg_p)) | 1U))
 
#define unmark_msg_remote(msg_p)   ((struct lp_msg *)(((uintptr_t)(msg_p)) - 2U))
 
#define unmark_msg_sent(msg_p)   ((struct lp_msg *)(((uintptr_t)(msg_p)) - 1U))
 

Functions

void ScheduleNewEvent (lp_id_t receiver, simtime_t timestamp, unsigned event_type, const void *payload, unsigned payload_size)
 API to inject a new event in the simulation. More...
 
static void checkpoint_take (struct lp_ctx *lp)
 Take a checkpoint of the state of a LP. More...
 
void process_lp_init (struct lp_ctx *lp)
 Initializes the processing module in the current LP.
 
void process_lp_fini (struct lp_ctx *lp)
 Finalize the processing module in the current LP.
 
static void silent_execution (const struct lp_ctx *lp, array_count_t last_i, array_count_t past_i)
 Perform silent execution of events. More...
 
static void send_anti_messages (struct process_ctx *proc_p, array_count_t past_i)
 Send anti-messages. More...
 
static void do_rollback (struct lp_ctx *lp, array_count_t past_i)
 Perform a rollback. More...
 
static array_count_t match_straggler_msg (const struct process_ctx *proc_p, const struct lp_msg *s_msg)
 Find the last valid processed message with respect to a straggler message. More...
 
static array_count_t match_anti_msg (const struct process_ctx *proc_p, const struct lp_msg *a_msg)
 Find the last valid processed message with respect to a received anti-message. More...
 
static void handle_remote_anti_msg (struct lp_ctx *lp, struct lp_msg *a_msg)
 Handle the reception of a remote anti-message. More...
 
static bool check_early_anti_messages (struct process_ctx *proc_p, struct lp_msg *msg)
 Check if a remote message has already been invalidated by an early remote anti-message. More...
 
static void handle_anti_msg (struct lp_ctx *lp, struct lp_msg *msg, uint32_t last_flags)
 Handle the reception of an anti-message. More...
 
static void handle_straggler_msg (struct lp_ctx *lp, struct lp_msg *msg)
 Handle the reception of a straggler message. More...
 
void process_msg (void)
 Extract and process a message, if available. More...
 

Variables

static __thread bool silent_processing = false
 The flag used in ScheduleNewEvent() to keep track of silent execution.
 
static __thread struct lp_msgcurrent_msg
 The currently processed message. More...
 

Detailed Description

LP state management functions.

This module contains the main logic for the parallel simulation runtime

Function Documentation

◆ check_early_anti_messages()

static bool check_early_anti_messages ( struct process_ctx proc_p,
struct lp_msg msg 
)
inlinestatic

Check if a remote message has already been invalidated by an early remote anti-message.

Parameters
proc_pthe message processing data of the current LP
a_msgthe remote message to check
Returns
true if the message has been matched with an early remote anti-message, false otherwise

◆ checkpoint_take()

static void checkpoint_take ( struct lp_ctx lp)
inlinestatic

Take a checkpoint of the state of a LP.

Parameters
lpthe LP to checkpoint

The actual checkpoint operation is delegated to the model memory allocator.

◆ do_rollback()

static void do_rollback ( struct lp_ctx lp,
array_count_t  past_i 
)
static

Perform a rollback.

Parameters
proc_pthe message processing data for the LP that has to rollback
past_ithe index in proc_p of the last validly processed message

◆ handle_anti_msg()

static void handle_anti_msg ( struct lp_ctx lp,
struct lp_msg msg,
uint32_t  last_flags 
)
static

Handle the reception of an anti-message.

Parameters
lpthe processing context of the current LP
msgthe received anti-message
last_flagsthe original value of the message flags before being modified by the current process_msg() call

◆ handle_remote_anti_msg()

static void handle_remote_anti_msg ( struct lp_ctx lp,
struct lp_msg a_msg 
)
inlinestatic

Handle the reception of a remote anti-message.

Parameters
proc_pthe message processing data for the LP that has to handle the anti-message
a_msgthe remote anti-message

◆ handle_straggler_msg()

static void handle_straggler_msg ( struct lp_ctx lp,
struct lp_msg msg 
)
static

Handle the reception of a straggler message.

Parameters
lpthe processing context of the current LP
msgthe received straggler message

◆ match_anti_msg()

static array_count_t match_anti_msg ( const struct process_ctx proc_p,
const struct lp_msg a_msg 
)
inlinestatic

Find the last valid processed message with respect to a received anti-message.

Parameters
proc_pthe message processing data for the LP
a_msgthe anti-message
Returns
the index in proc_p of the last validly processed message

◆ match_straggler_msg()

static array_count_t match_straggler_msg ( const struct process_ctx proc_p,
const struct lp_msg s_msg 
)
inlinestatic

Find the last valid processed message with respect to a straggler message.

Parameters
proc_pthe message processing data for the LP
s_msgthe straggler message
Returns
the index in proc_p of the last validly processed message

◆ process_msg()

void process_msg ( void  )

Extract and process a message, if available.

This function encloses most of the actual parallel/distributed simulation logic.

◆ ScheduleNewEvent()

void ScheduleNewEvent ( lp_id_t  receiver,
simtime_t  timestamp,
unsigned  event_type,
const void *  event_content,
unsigned  event_size 
)

API to inject a new event in the simulation.

This is a function pointer that is setup at simulation startup to point to either ScheduleNewEvent_parallel() in case of a parallel/distributed simulation, or to ScheduleNewEvent_serial() in case of a serial simulation.

Parameters
receiverThe ID of the LP that should receive the newly-injected message
timestampThe simulation time at which the event should be delivered at the recipient LP
event_typeNumerical event type to be passed to the model's dispatcher
event_contentThe event content
event_sizeThe size (in bytes) of the event content

◆ send_anti_messages()

static void send_anti_messages ( struct process_ctx proc_p,
array_count_t  past_i 
)
inlinestatic

Send anti-messages.

Parameters
proc_pthe message processing data for the LP that has to send anti-messages
past_ithe index in proc_p of the last validly processed message

◆ silent_execution()

static void silent_execution ( const struct lp_ctx lp,
array_count_t  last_i,
array_count_t  past_i 
)
inlinestatic

Perform silent execution of events.

Parameters
proc_pthe message processing data for the LP that has to coast forward
last_ithe index in proc_p of the last processed message in the current LP state
past_ithe target index in proc_p of the message to reach with the silent execution operation

This function implements the coasting forward operation done after a checkpoint has been restored.

Variable Documentation

◆ current_msg

__thread struct lp_msg* current_msg
static

The currently processed message.

This is not necessary for normal operation, but it's useful in debug