ROSS
ross-kernel-inline.h
Go to the documentation of this file.
1#ifndef INC_ross_kernel_inline_h
2#define INC_ross_kernel_inline_h
4#include "ross-extern.h"
5#include "ross-gvt-internal.h"
6#include "ross-network.h"
7
8#define ROSS_MAX(a,b) ((a) > (b) ? (a) : (b))
9#define ROSS_MIN(a,b) ((a) < (b) ? (a) : (b))
10
11static inline tw_lp *
13{
14 tw_lpid id = gid;
15
16 // finding analysis LPs doesn't depend on model's choice of mapping
18 {
20 }
21
22 switch (g_tw_mapping) {
23 case CUSTOM:
25 case ROUND_ROBIN:
26 id = gid / tw_nnodes();
27 break;
28 case LINEAR:
29 id = gid - g_tw_lp_offset;
30 break;
31 }
32
33#ifdef ROSS_runtime_checks
34 if (id >= g_tw_nlp)
35 tw_error(TW_LOC, "ID %d exceeded MAX LPs", id);
36 if (gid != g_tw_lp[id]->gid)
37 tw_error(TW_LOC, "Inconsistent LP Mapping");
38#endif /* ROSS_runtime_checks */
39
40 return g_tw_lp[id];
41}
42
43static inline tw_lp *
45{
46#ifdef ROSS_runtime_checks
47 if (id >= g_tw_nlp + g_st_analysis_nlp)
48 tw_error(TW_LOC, "ID %d exceeded MAX LPs", id);
49 if (id != g_tw_lp[id]->id)
50 tw_error(TW_LOC, "Inconsistent LP Mapping");
51#endif /* ROSS_runtime_checks */
52 return g_tw_lp[id];
53}
54
55static inline tw_kp *
57{
58#ifdef ROSS_runtime_checks
59 if (id >= g_tw_nkp)
60 tw_error(TW_LOC, "ID %u exceeded MAX KPs", id);
61 if( g_tw_kp[id] == NULL )
62 tw_error(TW_LOC, "Local KP %u found NULL \n", id );
63 if (id != g_tw_kp[id]->id)
64 tw_error(TW_LOC, "Inconsistent KP Mapping");
65#endif /* ROSS_runtime_checks */
66
67 return g_tw_kp[id];
68}
69
70static inline int
72{
73 return (g_tw_mynode == g_tw_masternode);
74}
75
76static inline void *
78{
79 return lp->cur_state;
80}
81
82#ifdef USE_RAND_TIEBREAKER
83static inline tw_stime
84 tw_now(tw_lp const * lp)
85{
86 return (lp->kp->last_sig.recv_ts);
87}
88
89static inline tw_event_sig
90 tw_now_sig(tw_lp const *lp)
91{
92 return (lp->kp->last_sig);
93}
94#else
95static inline tw_stime
96 tw_now(tw_lp const * lp)
97{
98 return (lp->kp->last_time);
99}
100#endif
101
102#endif
tw_lpid g_st_analysis_nlp
tw_lpid g_st_total_model_lps
int g_st_use_analysis_lps
unsigned tw_nnodes(void)
double tw_stime
Definition ross-base.h:39
uint64_t tw_lpid
Definition ross-base.h:49
tw_lp ** g_tw_lp
Definition ross-global.c:28
tw_kpid g_tw_nkp
Definition ross-global.c:27
tw_kp ** g_tw_kp
Definition ross-global.c:29
void tw_error(const char *file, int line, const char *fmt,...)
Definition tw-util.c:77
tw_peid g_tw_mynode
Definition ross-global.c:92
map_local_f g_tw_custom_lp_global_to_local_map
Definition ross-global.c:20
tw_lp_map g_tw_mapping
Definition ross-global.c:22
tw_lpid g_tw_nlp
Definition ross-global.c:24
tw_peid g_tw_masternode
Definition ross-global.c:93
tw_lpid g_tw_lp_offset
Definition ross-global.c:26
#define TW_LOC
static int tw_ismaster(void)
static tw_lp * tw_getlp(tw_lpid id)
static tw_stime tw_now(tw_lp const *lp)
static tw_event_sig tw_now_sig(tw_lp const *lp)
static void * tw_getstate(tw_lp *lp)
static tw_kp * tw_getkp(tw_kpid id)
static tw_lp * tw_getlocal_lp(tw_lpid gid)
tw_peid tw_kpid
Definition ross-types.h:55
@ CUSTOM
Definition ross-types.h:50
@ ROUND_ROBIN
Definition ross-types.h:49
@ LINEAR
Definition ross-types.h:48
tw_stime recv_ts
Definition ross-types.h:260
tw_event_sig last_sig
Event signature of the current event being processed.
Definition ross-types.h:398
tw_stime last_time
Time of the current event being processed.
Definition ross-types.h:401
LP State Structure.
Definition ross-types.h:336
tw_kp * kp
kp – Kernel process that we belong to (must match pe).
Definition ross-types.h:345
void * cur_state
Current application LP data.
Definition ross-types.h:347