ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
core.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include <float.h>
14 #include <limits.h>
15 #include <stdbool.h>
16 #include <stdint.h>
17 
18 #include <ROOT-Sim.h>
19 
20 #ifdef max
21 #undef max
22 #endif
24 #define max(a, b) \
25  __extension__({ \
26  __typeof__(a) _a = (a); \
27  __typeof__(b) _b = (b); \
28  _a > _b ? _a : _b; \
29  })
30 
31 #ifdef min
32 #undef min
33 #endif
35 #define min(a, b) \
36  __extension__({ \
37  __typeof__(a) _a = (a); \
38  __typeof__(b) _b = (b); \
39  _a < _b ? _a : _b; \
40  })
41 
42 #ifndef CACHE_LINE_SIZE // TODO: calculate and inject at build time
44 #define CACHE_LINE_SIZE 64
45 #endif
46 
47 #ifndef _MSC_VER
49 #define likely(exp) __builtin_expect(!!(exp), 1)
51 #define unlikely(exp) __builtin_expect((exp), 0)
52 #else
53 #define likely(exp) (exp)
54 #define unlikely(exp) (exp)
55 #endif
56 
58 #define SIMTIME_MAX DBL_MAX
59 
61 
62 #define MAX_NODES (1 << 16)
64 
65 #define MAX_THREADS_EXP 12
67 #define MAX_THREADS (1 << MAX_THREADS_EXP)
68 
70 typedef unsigned rid_t;
72 typedef int nid_t;
73 
75 extern lp_id_t n_lps_node;
77 extern __thread rid_t rid;
78 
80 extern nid_t n_nodes;
82 extern nid_t nid;
83 
85 extern char *core_version;
ROOT-Sim header for model development.
uint64_t lp_id_t
Logical Process ID data type.
Definition: ROOT-Sim.h:33
char * core_version
A string keeping the textual representation of the version of the core.
Definition: core.c:17
int nid_t
Used to identify MPI nodes in a distributed environment.
Definition: core.h:72
lp_id_t n_lps_node
The total number of LPs hosted in the node.
Definition: lp.c:29
nid_t n_nodes
The total number of MPI nodes in the simulation.
Definition: core.c:14
__thread rid_t rid
The identifier of the thread.
Definition: core.c:13
unsigned rid_t
Used to identify in a node the computing resources (threads at the moment)
Definition: core.h:70
struct simulation_configuration global_config
The global configuration of the simulation, passed by the model.
Definition: init.c:27
nid_t nid
The node identifier of the node.
Definition: core.c:15
A set of configurable values used by other modules.
Definition: ROOT-Sim.h:210