ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
lp.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include <arch/platform.h>
14 #include <core/core.h>
15 #include <lib/random/random.h>
16 #include <lp/msg.h>
17 #include <lp/process.h>
18 #include <mm/auto_ckpt.h>
19 #include <mm/model_allocator.h>
20 
22 struct lp_ctx {
26  struct rng_ctx *rng_ctx;
30  unsigned fossil_epoch;
32  struct auto_ckpt auto_ckpt;
34  struct process_ctx p;
36  struct mm_state mm_state;
37 };
38 
44 #define lid_to_nid(lp_id) ((nid_t)((lp_id) * n_nodes / global_config.lps))
45 
53 #define lid_to_rid(lp_id) ((rid_t)(((lp_id) - lid_node_first) * global_config.n_threads / n_lps_node))
54 
55 extern uint64_t lid_node_first;
56 extern __thread uint64_t lid_thread_first;
57 extern __thread uint64_t lid_thread_end;
58 
59 extern __thread struct lp_ctx *current_lp;
60 extern struct lp_ctx *lps;
61 
62 #ifndef NDEBUG
63 extern bool lp_initialized;
64 #define lp_initialized_set() (lp_initialized = true)
65 #else
66 #define lp_initialized_set()
67 #endif
68 
69 extern void lp_global_init(void);
70 extern void lp_global_fini(void);
71 
72 extern void lp_init(void);
73 extern void lp_fini(void);
double simtime_t
Simulation time data type.
Definition: ROOT-Sim.h:27
Autonomic checkpoint interval selection header.
Core ROOT-Sim functionalities.
void lp_fini(void)
Finalize the data structures of the LPs hosted in the calling thread.
Definition: lp.c:112
uint64_t lid_node_first
The lowest LP id between the ones hosted on this node.
Definition: lp.c:18
__thread struct lp_ctx * current_lp
A pointer to the currently processed LP context.
Definition: lp.c:24
__thread uint64_t lid_thread_first
The lowest LP id between the ones hosted on this thread.
Definition: lp.c:20
void lp_global_fini(void)
Finalize the global data structures for the LPs.
Definition: lp.c:78
struct lp_ctx * lps
A pointer to the LP contexts array.
Definition: lp.c:27
void lp_init(void)
Initialize the data structures of the LPs hosted in the calling thread.
Definition: lp.c:87
__thread uint64_t lid_thread_end
One plus the highest LP id between the ones hosted on this thread.
Definition: lp.c:22
void lp_global_init(void)
Initialize the global data structures for the LPs.
Definition: lp.c:60
Memory management functions for simulation models.
Message management functions.
Determine on what OS we are compiling.
LP state management functions.
Random Number Generators.
Structure to keep data used for autonomic checkpointing selection.
Definition: auto_ckpt.h:16
A complete LP context.
Definition: lp.h:22
unsigned fossil_epoch
The housekeeping epoch number.
Definition: lp.h:30
struct process_ctx p
The message processing context of this LP.
Definition: lp.h:34
simtime_t termination_t
The termination time of this LP, handled by the termination module.
Definition: lp.h:24
struct rng_ctx * rng_ctx
The additional libraries context of this LP.
Definition: lp.h:26
void * state_pointer
The pointer set by the model with the SetState() API call.
Definition: lp.h:28
The checkpointable memory context assigned to a single LP.
Definition: multi.h:35
The message processing data produced by the LP.
Definition: process.h:17
The container for the pseudo random number generator context.
Definition: random.h:18