The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
ROOT-Sim.h
Go to the documentation of this file.
1 
38 #pragma once
39 
40 #include <stdlib.h>
41 #include <stdio.h>
42 #include <stdint.h>
43 #include <string.h>
44 #include <stdbool.h>
45 #include <float.h>
46 #include <limits.h>
47 #include <argp.h>
48 
49 #ifdef INIT
50 #undef INIT
51 #endif
52 #define INIT 0
54 
56 typedef double simtime_t;
57 
59 #define INFTY DBL_MAX
60 
62 extern unsigned int n_prc_tot;
63 
65 __attribute((weak))
66 extern struct argp model_argp;
67 
68 // Expose to the application level the rollbackable numerical library
69 double Random(void);
70 int RandomRange(int min, int max);
71 int RandomRangeNonUniform(int x, int min, int max);
72 double Expent(double mean);
73 double Normal(void);
74 double Gamma(int ia);
75 double Poisson(void);
76 int Zipf(double skew, int limit);
77 
78 // ROOT-Sim core API
79 extern void (*ScheduleNewEvent)(unsigned int receiver, simtime_t timestamp, unsigned int event_type, void *event_content, unsigned int event_size);
80 extern void SetState(void *new_state);
81 
82 /*********************************/
83 /********TOPOLOGY*LIBRARY*********/
84 /*********************************/
85 
98 };
99 
113 typedef enum _direction_t {
116 
119 
124 
125  DIRECTION_INVALID = UINT_MAX
126 } direction_t;
127 
132 };
133 
137 __attribute((weak)) extern struct _topology_settings_t{
138  const char * const topology_path;
139  const enum _topology_type_t type;
140  const enum _topology_geometry_t default_geometry;
141  const unsigned out_of_topology;
142  const bool write_enabled;
143 }topology_settings;
144 
151 double GetValueTopology(unsigned from, unsigned to);
152 
171 void SetValueTopology(unsigned from, unsigned to, double value);
172 
173 // finds a receiver with probabilities weighted on neighbours link (works only for topology type TOPOLOGY_PROBABILITIES)
174 unsigned int FindReceiver (void);
175 
176 // returns the count of regions involved in the topology (can be less than n_prc_tot)
177 unsigned int RegionsCount (void);
178 
179 // returns the maximum count of neighbours this region has, this is made to simplify direction handling (need to explain better xxx)
180 unsigned int DirectionsCount (void);
181 
182 // returns the actual count of neighbours this region has (if this is called from a region on the edge of the topology
183 unsigned int NeighboursCount (unsigned int region);
184 
185 // Returns DIRECTION_INVALID if a movement is not possible according to the given topology
186 unsigned int GetReceiver (unsigned int from, direction_t direction, bool reachable);
187 
188 // this returns the next hop to reach region to following a minimum cost path: it's far less costly than to recompute a new path with ComputeMinTour()
189 unsigned int FindReceiverToward (unsigned int to);
190 
191 // Function to return a list of LP IDs to be visited in order to reach a given cell with minimum cost.
192 // -1.0 is returned is no path is available else the total cost is returned
193 double ComputeMinTour (unsigned int source, unsigned int dest, unsigned int result[RegionsCount()]);
194 
195 /*********************************/
196 /************ABM*LIBRARY**********/
197 /*********************************/
198 
199 typedef unsigned long long agent_t;
200 
201 __attribute((weak)) extern struct _abm_settings_t{
202  const unsigned neighbour_data_size;
203  const unsigned traverse_handler;
204  const bool keep_history;
205 } abm_settings;
206 
207 int GetNeighbourInfo (direction_t i, unsigned int *region_id, void **data_p);
208 void TrackNeighbourInfo (void *neighbour_data);
209 
210 bool IterAgents (agent_t *agent_p);
211 unsigned CountAgents (void);
212 
213 agent_t SpawnAgent (unsigned user_data_size);
214 void KillAgent (agent_t agent);
215 
216 void* DataAgent (agent_t agent, unsigned *data_size_p);
217 
218 void ScheduleNewLeaveEvent (simtime_t time, unsigned int event_type, agent_t agent);
219 
220 unsigned CountVisits (const agent_t agent);
221 void GetVisit (const agent_t agent, unsigned *region_p, unsigned *event_type_p, unsigned i);
222 void SetVisit (const agent_t agent, unsigned region, unsigned event_type, unsigned i);
223 void EnqueueVisit (agent_t agent, unsigned region, unsigned event_type);
224 void AddVisit (agent_t agent, unsigned region, unsigned event_type, unsigned i);
225 void RemoveVisit (agent_t agent, unsigned i);
226 
227 unsigned CountPastVisits (const agent_t agent);
228 void GetPastVisit (const agent_t agent, unsigned *region_p, unsigned *event_type_p, simtime_t *time_p, unsigned i);
229 
230 
231 /************* CAPABILITIES ************/
232 
246 {
247  /* Capabilities always enabled */
248  CAP_SCHEDULER,
249  CAP_CKTRM_MODE,
250  CAP_LPS_DISTRIBUTION,
251  CAP_STATS,
252  CAP_STATE_SAVING,
253  CAP_THREADS,
254  CAP_LPS,
255  CAP_OUTPUT_DIR,
256  CAP_P,
257  CAP_GVT,
258  CAP_GVT_SNAPSHOT_CYCLES,
259  CAP_SEED,
260  CAP_VERBOSE,
261 
262  /* Optional capabilities */
263  CAP_NPWD,
264  CAP_FULL,
265  CAP_INC,
266  CAP_A,
267  CAP_SIMULATION_TIME,
268  CAP_DETERMINISTIC_SEED,
269  CAP_SERIAL,
270  CAP_CORE_BINDING,
271  CAP_PREEMPTION,
272  CAP_ECS,
273  CAP_LINUX_MODULES,
274  CAP_LP_REBINDING,
275  CAP_MPI,
276  CAP_SILENT
277 };
278 
280  enum capability_t capability;
281  union {
282  const char *output_dir;
283  int scheduler;
291  int verbose;
292  int stats;
293  int lps;
294  uint64_t seed;
295  };
296 };
297 
321 bool CapabilityAvailable(enum capability_t which, struct capability_info_t *info);
uint64_t seed
The master seed to be used in this run.
Definition: ROOT-Sim.h:294
all crossing costs and probabilities are set to 1, but there can be not crossable regions ...
Definition: ROOT-Sim.h:129
unsigned int n_prc_tot
This is the definition of the number of LPs running in the current simulation.
Definition: core.c:64
DIRECTION_W.
Definition: ROOT-Sim.h:115
#define min(a, b)
Macro to find the minimum among two values.
Definition: core.h:115
int lps
Number of active logical processes.
Definition: ROOT-Sim.h:293
double Expent(double mean)
Definition: numerical.c:120
A generic invalid direction.
Definition: ROOT-Sim.h:125
DIRECTION_SE.
Definition: ROOT-Sim.h:123
double Normal(void)
Definition: numerical.c:141
DIRECTION_E.
Definition: ROOT-Sim.h:114
DIRECTION_N.
Definition: ROOT-Sim.h:117
FIXME.
Definition: ROOT-Sim.h:96
_direction_t
Definition: ROOT-Sim.h:113
square grid topology
Definition: ROOT-Sim.h:92
int verbose
Kernel verbose.
Definition: ROOT-Sim.h:291
DIRECTION_NW.
Definition: ROOT-Sim.h:122
int ckpt_period
Number of events to execute before taking a snapshot in PSS (ignored otherwise)
Definition: ROOT-Sim.h:289
int scheduler
Which scheduler to be used.
Definition: ROOT-Sim.h:283
double GetValueTopology(unsigned from, unsigned to)
Definition: topology.c:288
int simulation_time
Wall-clock-time based termination predicate.
Definition: ROOT-Sim.h:285
_topology_geometry_t
Definition: ROOT-Sim.h:89
a torus shaped grid topology (a wrapping around square topology)
Definition: ROOT-Sim.h:95
int stats
Produce performance statistic file (default STATS_ALL)
Definition: ROOT-Sim.h:292
int gvt_time_period
Wall-Clock time to wait before executiong GVT operations.
Definition: ROOT-Sim.h:284
DIRECTION_S.
Definition: ROOT-Sim.h:118
double Gamma(int ia)
Definition: numerical.c:179
double Poisson(void)
Definition: numerical.c:223
int lps_distribution
Policy for the LP to Kernel mapping.
Definition: ROOT-Sim.h:286
hexagonal grid topology
Definition: ROOT-Sim.h:91
double simtime_t
This defines the type with whom timestamps are represented.
Definition: ROOT-Sim.h:56
void SetValueTopology(unsigned from, unsigned to, double value)
Definition: topology.c:261
decisions are taken at random but are weighted on the palatability of neighbours
Definition: ROOT-Sim.h:131
capability_t
Capability enumeration.
Definition: ROOT-Sim.h:245
__attribute((weak)) extern struct argp model_argp
This can be implemented by the model for smart argument handling.
Definition: ROOT-Sim.h:137
enum _direction_t direction_t
void(* ScheduleNewEvent)(unsigned int receiver, simtime_t timestamp, unsigned int event_type, void *event_content, unsigned int event_size)
This is the function pointer to correctly set ScheduleNewEvent API version, depending if we&#39;re runnin...
Definition: communication.c:50
int checkpointing
Type of checkpointing scheme (e.g., PSS, CSS, ...)
Definition: ROOT-Sim.h:288
double Random(void)
Definition: numerical.c:80
#define max(a, b)
Macro to find the maximum among two values.
Definition: core.h:106
an arbitrary shaped topology
Definition: ROOT-Sim.h:97
a ring shaped topology direction
Definition: ROOT-Sim.h:94
bool CapabilityAvailable(enum capability_t which, struct capability_info_t *info)
Query runtime capabilities while executing the model.
Definition: init.c:461
arbitrary offset used to distinguish during debug different enums
Definition: ROOT-Sim.h:90
DIRECTION_SW.
Definition: ROOT-Sim.h:121
decisions on next hops are taken based on the costs undertaken to cross the boundaries ...
Definition: ROOT-Sim.h:130
a ring shaped topology walkable in a single direction
Definition: ROOT-Sim.h:93
_topology_type_t
Definition: ROOT-Sim.h:128
const char * output_dir
Destination Directory of output files.
Definition: ROOT-Sim.h:282
void SetState(void *new_state)
Definition: state.c:323
int state_saving
Type of checkpointing mode (Synchronous, Semi-Asyncronous, ...)
Definition: ROOT-Sim.h:287
int termination_mode
Check termination strategy: standard or incremental.
Definition: ROOT-Sim.h:290
int Zipf(double skew, int limit)
Definition: numerical.c:237
DIRECTION_NE.
Definition: ROOT-Sim.h:120