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 
5 #define ROSS_MAX(a,b) ((a) > (b) ? (a) : (b))
6 #define ROSS_MIN(a,b) ((a) < (b) ? (a) : (b))
7 
8 static inline tw_lp *
10 {
11  tw_lpid id = gid;
12 
13  // finding analysis LPs doesn't depend on model's choice of mapping
15  {
16  return g_tw_lp[(gid - g_st_total_model_lps) % g_tw_nkp + g_tw_nlp];
17  }
18 
19  switch (g_tw_mapping) {
20  case CUSTOM:
21  return( g_tw_custom_lp_global_to_local_map( gid ) );
22  case ROUND_ROBIN:
23  id = gid / tw_nnodes();
24  break;
25  case LINEAR:
26  id = gid - g_tw_lp_offset;
27  break;
28  }
29 
30 #ifdef ROSS_runtime_checks
31  if (id >= g_tw_nlp)
32  tw_error(TW_LOC, "ID %d exceeded MAX LPs", id);
33  if (gid != g_tw_lp[id]->gid)
34  tw_error(TW_LOC, "Inconsistent LP Mapping");
35 #endif /* ROSS_runtime_checks */
36 
37  return g_tw_lp[id];
38 }
39 
40 static inline tw_lp *
42 {
43 #ifdef ROSS_runtime_checks
44  if (id >= g_tw_nlp + g_st_analysis_nlp)
45  tw_error(TW_LOC, "ID %d exceeded MAX LPs", id);
46  if (id != g_tw_lp[id]->id)
47  tw_error(TW_LOC, "Inconsistent LP Mapping");
48 #endif /* ROSS_runtime_checks */
49  return g_tw_lp[id];
50 }
51 
52 static inline tw_kp *
54 {
55 #ifdef ROSS_runtime_checks
56  if (id >= g_tw_nkp)
57  tw_error(TW_LOC, "ID %u exceeded MAX KPs", id);
58  if( g_tw_kp[id] == NULL )
59  tw_error(TW_LOC, "Local KP %u found NULL \n", id );
60  if (id != g_tw_kp[id]->id)
61  tw_error(TW_LOC, "Inconsistent KP Mapping");
62 #endif /* ROSS_runtime_checks */
63 
64  return g_tw_kp[id];
65 }
66 
67 static inline int
69 {
70  return (g_tw_mynode == g_tw_masternode);
71 }
72 
73 static inline void *
75 {
76  return lp->cur_state;
77 }
78 
79 static inline tw_stime
80  tw_now(tw_lp const * lp)
81 {
82  return (lp->kp->last_time);
83 }
84 
85 #endif
#define TW_LOC
Definition: ross-extern.h:164
tw_lp ** g_tw_lp
Definition: ross-global.c:26
double tw_stime
Definition: ross.h:150
void tw_error(const char *file, int line, const char *fmt,...) NORETURN
Definition: tw-util.c:74
tw_lpid g_tw_lp_offset
Definition: ross-global.c:24
static int tw_ismaster(void)
tw_lpid g_tw_nlp
Definition: ross-global.c:23
unsigned int tw_nnodes(void)
Definition: network-mpi.c:103
static tw_kp * tw_getkp(tw_kpid id)
uint64_t tw_lpid
Definition: ross.h:160
tw_kp * kp
kp – Kernel process that we belong to (must match pe).
Definition: ross-types.h:313
tw_lpid g_st_analysis_nlp
map_local_f g_tw_custom_lp_global_to_local_map
Definition: ross-global.c:19
int g_st_use_analysis_lps
static tw_stime tw_now(tw_lp const *lp)
tw_lp_map g_tw_mapping
Definition: ross-global.c:21
tw_peid g_tw_mynode
Definition: ross-global.c:88
tw_lpid g_st_total_model_lps
tw_peid g_tw_masternode
Definition: ross-global.c:89
static tw_lp * tw_getlp(tw_lpid id)
static void * tw_getstate(tw_lp *lp)
tw_peid tw_kpid
Definition: ross-types.h:45
void * cur_state
Current application LP data.
Definition: ross-types.h:315
tw_kpid g_tw_nkp
Definition: ross-global.c:25
static tw_lp * tw_getlocal_lp(tw_lpid gid)
tw_stime last_time
Time of the current event being processed.
Definition: ross-types.h:360
LP State Structure.
Definition: ross-types.h:304
tw_kp ** g_tw_kp
Definition: ross-global.c:27