30 #define SIMTIME_MAX DBL_MAX
53 unsigned event_size,
void *st);
71 enum rootsim_event {LP_INIT = 65534, LP_FINI};
89 extern void SetState(
void *new_state);
91 extern void *rs_malloc(
size_t req_size);
92 extern void *rs_calloc(
size_t nmemb,
size_t size);
93 extern void rs_free(
void *ptr);
94 extern void *rs_realloc(
void *ptr,
size_t req_size);
96 extern double Random(
void);
99 #define Expent(mean) ((mean) * Poisson())
100 extern double Normal(
void);
101 extern int RandomRange(
int min,
int max);
102 extern int RandomRangeNonUniform(
int x,
int min,
int max);
103 extern double Gamma(
unsigned ia);
104 extern unsigned Zipf(
double skew,
unsigned limit);
145 #define INVALID_DIRECTION UINT64_MAX
160 #define PP_NARG(...) \
161 PP_NARG_(__VA_ARGS__,PP_RSEQ_N())
163 #define PP_NARG_(...) \
164 PP_128TH_ARG(__VA_ARGS__)
166 #define PP_128TH_ARG( \
167 _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
168 _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
169 _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
170 _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
171 _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
172 _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
173 _61,_62,_63,_64,_65,_66,_67,_68,_69,_70, \
174 _71,_72,_73,_74,_75,_76,_77,_78,_79,_80, \
175 _81,_82,_83,_84,_85,_86,_87,_88,_89,_90, \
176 _91,_92,_93,_94,_95,_96,_97,_98,_99,_100, \
177 _101,_102,_103,_104,_105,_106,_107,_108,_109,_110, \
178 _111,_112,_113,_114,_115,_116,_117,_118,_119,_120, \
179 _121,_122,_123,_124,_125,_126,_127,N,...) N
181 #define PP_RSEQ_N() \
182 127,126,125,124,123,122,121,120, \
183 119,118,117,116,115,114,113,112,111,110, \
184 109,108,107,106,105,104,103,102,101,100, \
185 99,98,97,96,95,94,93,92,91,90, \
186 89,88,87,86,85,84,83,82,81,80, \
187 79,78,77,76,75,74,73,72,71,70, \
188 69,68,67,66,65,64,63,62,61,60, \
189 59,58,57,56,55,54,53,52,51,50, \
190 49,48,47,46,45,44,43,42,41,40, \
191 39,38,37,36,35,34,33,32,31,30, \
192 29,28,27,26,25,24,23,22,21,20, \
193 19,18,17,16,15,14,13,12,11,10, \
206 #define InitializeTopology(geometry, ...) vInitializeTopology(geometry, PP_NARG(__VA_ARGS__), __VA_ARGS__)
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.
Definition: process.c:38
int RootsimRun(void)
Start the simulation.
Definition: init.c:134
void(* ProcessEvent_t)(lp_id_t me, simtime_t now, unsigned event_type, const void *event_content, unsigned event_size, void *st)
ProcessEvent callback function.
Definition: ROOT-Sim.h:52
bool(* CanEnd_t)(lp_id_t me, const void *snapshot)
Determine if simulation can be halted.
Definition: ROOT-Sim.h:69
topology_geometry
Definition: ROOT-Sim.h:120
@ TOPOLOGY_SQUARE
square grid topology
Definition: ROOT-Sim.h:122
@ TOPOLOGY_STAR
a star shaped topology
Definition: ROOT-Sim.h:126
@ TOPOLOGY_GRAPH
a (weighted) graph topology
Definition: ROOT-Sim.h:128
@ TOPOLOGY_TORUS
a torus shaped grid topology (a wrapping around square topology)
Definition: ROOT-Sim.h:123
@ TOPOLOGY_FCMESH
a fully-connected mesh
Definition: ROOT-Sim.h:127
@ TOPOLOGY_HEXAGON
hexagonal grid topology
Definition: ROOT-Sim.h:121
@ TOPOLOGY_BIDRING
a ring shaped topology
Definition: ROOT-Sim.h:125
@ TOPOLOGY_RING
a ring shaped topology walkable in a single direction
Definition: ROOT-Sim.h:124
double simtime_t
Simulation time data type.
Definition: ROOT-Sim.h:27
uint64_t RandomU64(void)
Return a random 64-bit value.
Definition: random.c:41
unsigned Zipf(double skew, unsigned limit)
Return a random sample from a Zipf distribution Based on the rejection method by Luc Devroye for samp...
Definition: random.c:152
double Poisson(void)
Return a random number according to an Exponential distribution with unit mean Corresponds to the wai...
Definition: random.c:138
void SetState(void *new_state)
Set the LP simulation state main pointer.
Definition: lp.c:128
topology_direction
Definition: ROOT-Sim.h:131
@ DIRECTION_N
North direction.
Definition: ROOT-Sim.h:134
@ DIRECTION_NE
North-east direction.
Definition: ROOT-Sim.h:136
@ DIRECTION_SW
South-west direction.
Definition: ROOT-Sim.h:137
@ DIRECTION_RANDOM
Get a random direction, depending on the topology.
Definition: ROOT-Sim.h:141
@ DIRECTION_SE
South-east direction.
Definition: ROOT-Sim.h:139
@ DIRECTION_E
East direction.
Definition: ROOT-Sim.h:132
@ DIRECTION_W
West direction.
Definition: ROOT-Sim.h:133
@ DIRECTION_NW
North-west direction.
Definition: ROOT-Sim.h:138
@ DIRECTION_S
South direction.
Definition: ROOT-Sim.h:135
log_level
Definition: ROOT-Sim.h:107
@ LOG_ERROR
The logging level reserved to unexpected, problematic conditions.
Definition: ROOT-Sim.h:112
@ LOG_SILENT
Emit no message during the simulation.
Definition: ROOT-Sim.h:114
@ LOG_TRACE
The logging level reserved to very low priority messages.
Definition: ROOT-Sim.h:108
@ LOG_INFO
The logging level reserved to useful runtime messages.
Definition: ROOT-Sim.h:110
@ LOG_DEBUG
The logging level reserved to useful debug messages.
Definition: ROOT-Sim.h:109
@ LOG_FATAL
The logging level reserved to unexpected, fatal conditions.
Definition: ROOT-Sim.h:113
@ LOG_WARN
The logging level reserved to unexpected, non deal breaking conditions.
Definition: ROOT-Sim.h:111
double Normal(void)
Return a pair of independent random numbers according to a Standard Normal Distribution.
Definition: random.c:73
double Gamma(unsigned ia)
Return a number in according to a Gamma Distribution of Integer Order ia Corresponds to the waiting t...
Definition: random.c:104
int RootsimInit(const struct simulation_configuration *conf)
Initialize the core library.
Definition: init.c:91
uint64_t lp_id_t
Logical Process ID data type.
Definition: ROOT-Sim.h:33
double Random(void)
Return a random value in [0,1] according to a uniform distribution.
Definition: random.c:51
void RootsimStop(void)
Force termination of the simulation.
Definition: termination.c:86
struct topology * vInitializeTopology(enum topology_geometry geometry, int argc,...)
Initialize a topology region.
Definition: topology.c:587
#define min(a, b)
Statement expression to compute the min between two values with no double evaluation side effect.
Definition: core.h:35
#define max(a, b)
Statement expression to compute the max between two values with no double evaluation side effect.
Definition: core.h:24
A set of configurable values used by other modules.
Definition: ROOT-Sim.h:210
enum log_level log_level
The logger verbosity level.
Definition: ROOT-Sim.h:220
unsigned gvt_period
The gvt period expressed in microseconds.
Definition: ROOT-Sim.h:218
CanEnd_t committed
Function pointer to the termination detection function.
Definition: ROOT-Sim.h:236
const char * stats_file
Path to the statistics file. If NULL, no statistics are produced.
Definition: ROOT-Sim.h:224
lp_id_t lps
The number of LPs to be used in the simulation.
Definition: ROOT-Sim.h:212
uint64_t prng_seed
The seed used to initialize the pseudo random numbers.
Definition: ROOT-Sim.h:228
bool serial
If set, the simulation will run on the serial runtime.
Definition: ROOT-Sim.h:232
FILE * logfile
File where to write logged information: if not NULL, output is redirected to this file.
Definition: ROOT-Sim.h:222
unsigned ckpt_interval
The checkpointing interval.
Definition: ROOT-Sim.h:226
ProcessEvent_t dispatcher
Function pointer to the dispatching function.
Definition: ROOT-Sim.h:234
simtime_t termination_time
The target termination logical time. Setting this value to zero means that LVT-based termination is d...
Definition: ROOT-Sim.h:216
bool core_binding
If set, worker threads are bound to physical cores.
Definition: ROOT-Sim.h:230
unsigned n_threads
The number of threads to be used in the simulation. If zero, it defaults to the amount of available c...
Definition: ROOT-Sim.h:214
The structure describing a topology.
Definition: topology.c:28
enum topology_geometry geometry
Definition: topology.c:32