The ROme OpTimistic Simulator  3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
ROOT-Sim.h
Go to the documentation of this file.
1 
16 #pragma once
17 
18 #include <limits.h>
19 #include <stdbool.h>
20 #include <stdint.h>
21 #include <stdlib.h>
22 
23 enum rootsim_event {
24  MODEL_INIT = 65532,
25  LP_INIT,
26  LP_FINI,
27  MODEL_FINI
28 };
29 
30 typedef double simtime_t;
31 typedef uint64_t lp_id_t;
32 
33 struct ap_option {
34  const char *name;
35  int key;
36  const char *arg;
37  const char *doc;
38 };
39 
41  AP_KEY_INIT = 1 << 14,
43 };
44 
45 __attribute((weak)) extern struct ap_option model_options[];
46 __attribute((weak)) extern void model_parse(int key, const char *arg);
47 
48 extern lp_id_t n_lps;
49 
50 extern void ScheduleNewEvent(lp_id_t receiver, simtime_t timestamp,
51  unsigned event_type, const void *event_content, unsigned event_size);
52 
53 extern void SetState(void *new_state);
54 
55 extern double Random(void);
56 extern uint64_t RandomU64(void);
57 extern double Expent(double mean);
58 extern double Normal(void);
59 
68 };
69 
79 
80  // FIXME this is bad if the n_lps is more than INT_MAX - 1
81  DIRECTION_INVALID = INT_MAX
82 };
83 
84 extern struct topology_settings_t {
87 } topology_settings;
88 
89 extern __attribute__ ((pure)) lp_id_t RegionsCount(void);
90 extern __attribute__ ((pure)) lp_id_t DirectionsCount(void);
91 extern __attribute__ ((pure)) lp_id_t GetReceiver(lp_id_t from, enum _direction_t direction);
92 extern lp_id_t FindReceiver(void);
__attribute
__attribute((weak))
this is used to store the common characteristics of the topology
Definition: topology.c:19
simtime_t
double simtime_t
The type used to represent logical time in the simulation.
Definition: core.h:62
DIRECTION_NE
@ DIRECTION_NE
North-east direction.
Definition: ROOT-Sim.h:75
ap_option::arg
const char * arg
The argument name for this option, shown in the --usage text.
Definition: arg_parse.h:22
DIRECTION_NW
@ DIRECTION_NW
North-west direction.
Definition: ROOT-Sim.h:77
ap_option
A single parsable command line option.
Definition: arg_parse.h:14
TOPOLOGY_SQUARE
@ TOPOLOGY_SQUARE
square grid topology
Definition: ROOT-Sim.h:62
DIRECTION_INVALID
@ DIRECTION_INVALID
A generic invalid direction.
Definition: ROOT-Sim.h:81
topology_settings_t::out_of_topology
lp_id_t out_of_topology
The minimum number of LPs needed for out of the topology logic.
Definition: topology.h:49
TOPOLOGY_MESH
@ TOPOLOGY_MESH
an arbitrary shaped topology
Definition: ROOT-Sim.h:67
TOPOLOGY_STAR
@ TOPOLOGY_STAR
a star shaped topology
Definition: ROOT-Sim.h:66
DIRECTION_SW
@ DIRECTION_SW
South-west direction.
Definition: ROOT-Sim.h:76
AP_KEY_INIT
@ AP_KEY_INIT
Signals the start of the parsing process.
Definition: arg_parse.h:31
ap_option::doc
const char * doc
The documentation of this option, shown in the --help text.
Definition: arg_parse.h:25
DIRECTION_E
@ DIRECTION_E
East direction.
Definition: ROOT-Sim.h:73
ap_option::key
int key
The key passed to the parsing function when encountering this option.
Definition: arg_parse.h:19
AP_KEY_FINI
@ AP_KEY_FINI
Signals the end of the parsing process.
Definition: arg_parse.h:33
Expent
double Expent(double mean)
Definition: random.c:61
n_lps
lp_id_t n_lps
The total number of LPs in the simulation.
Definition: core.c:13
DIRECTION_S
@ DIRECTION_S
South direction.
Definition: ROOT-Sim.h:72
TOPOLOGY_TORUS
@ TOPOLOGY_TORUS
a torus shaped grid topology (a wrapping around square topology)
Definition: ROOT-Sim.h:65
DIRECTION_W
@ DIRECTION_W
West direction.
Definition: ROOT-Sim.h:74
TOPOLOGY_BIDRING
@ TOPOLOGY_BIDRING
a ring shaped topology
Definition: ROOT-Sim.h:64
_topology_geometry_t
_topology_geometry_t
Definition: topology.h:20
DIRECTION_N
@ DIRECTION_N
North direction.
Definition: ROOT-Sim.h:71
ap_event_key
ap_event_key
The special events keys passed to command line parsing functions.
Definition: arg_parse.h:29
_direction_t
_direction_t
Definition: topology.h:30
Normal
double Normal(void)
Definition: random.c:74
lp_id_t
uint64_t lp_id_t
Used to uniquely identify LPs in the simulation.
Definition: core.h:75
ap_option::name
const char * name
The long option name.
Definition: arg_parse.h:16
TOPOLOGY_RING
@ TOPOLOGY_RING
a ring shaped topology walkable in a single direction
Definition: ROOT-Sim.h:63
topology_settings_t::default_geometry
enum _topology_geometry_t default_geometry
The default geometry to use when nothing else is specified.
Definition: topology.h:47
TOPOLOGY_HEXAGON
@ TOPOLOGY_HEXAGON
hexagonal grid topology
Definition: ROOT-Sim.h:61
DIRECTION_SE
@ DIRECTION_SE
South-east direction.
Definition: ROOT-Sim.h:78
topology_settings_t
This is declared by the model to setup the topology module.
Definition: topology.h:45