ROSS
phold.c
Go to the documentation of this file.
1 #include "phold.h"
2 
3 
6 {
7  return (tw_peid) gid / g_tw_nlp;
8 }
9 
10 void
12 {
13  (void) s;
14  int i;
15 
16  if( stagger )
17  {
18  for (i = 0; i < g_phold_start_events; i++)
19  {
21  tw_event_new(lp->gid,
22  tw_rand_exponential(lp->rng, mean) + lookahead + (tw_stime)(lp->gid % (unsigned int)g_tw_ts_end),
23  lp));
24  }
25  }
26  else
27  {
28  for (i = 0; i < g_phold_start_events; i++)
29  {
31  tw_event_new(lp->gid,
33  lp));
34  }
35  }
36 }
37 
38 void
40 {
41  (void) s;
42  tw_lpid dest;
43 
44  if(tw_rand_unif(lp->rng) <= percent_remote)
45  {
46  dest = tw_rand_integer(lp->rng, 0, ttl_lps - 1);
47  } else
48  {
49  dest = lp->gid;
50  }
51 
52  if(dest >= (g_tw_nlp * tw_nnodes()))
53  tw_error(TW_LOC, "bad dest");
54 
56 }
57 
58 void
60 {
61  (void) s;
62  (void) m;
63  tw_lpid dest;
64 
65  if(tw_rand_unif(lp->rng) <= percent_remote)
66  {
67  bf->c1 = 1;
68  dest = tw_rand_integer(lp->rng, 0, ttl_lps - 1);
69  // Makes PHOLD non-deterministic across processors! Don't uncomment
70  /* dest += offset_lpid; */
71  /* if(dest >= ttl_lps) */
72  /* dest -= ttl_lps; */
73  } else
74  {
75  bf->c1 = 0;
76  dest = lp->gid;
77  }
78 
79  if(dest >= (g_tw_nlp * tw_nnodes()))
80  tw_error(TW_LOC, "bad dest");
81 
83 }
84 
85 void
87 {
88  (void) s;
89  (void) m;
92 
93  if(bf->c1 == 1)
95 }
96 
97 void phold_commit(phold_state * s, tw_bf * bf, phold_message * m, tw_lp * lp)
98 {
99  (void) s;
100  (void) bf;
101  (void) m;
102  (void) lp;
103 }
104 
105 void
107 {
108  (void) s;
109  (void) lp;
110 }
111 
113  {(init_f) phold_init,
114  /* (pre_run_f) phold_pre_run, */
115  (pre_run_f) NULL,
120  (map_f) phold_map,
121  sizeof(phold_state)},
122  {0},
123 };
124 
125 void event_trace(phold_message *m, tw_lp *lp, char *buffer, int *collect_flag)
126 {
127  (void) m;
128  (void) lp;
129  (void) buffer;
130  (void) collect_flag;
131  return;
132 }
133 
134 void phold_stats_collect(phold_state *s, tw_lp *lp, char *buffer)
135 {
136  (void) s;
137  (void) lp;
138  (void) buffer;
139  return;
140 }
141 
144  0,
146  sizeof(int),
147  NULL, //(sample_event_f)
148  NULL, //(sample_revent_f)
149  0},
150  {0}
151 };
152 
154 {
155  TWOPT_GROUP("PHOLD Model"),
156  TWOPT_DOUBLE("remote", percent_remote, "desired remote event rate"),
157  TWOPT_UINT("nlp", nlp_per_pe, "number of LPs per processor"),
158  TWOPT_DOUBLE("mean", mean, "exponential distribution mean for timestamps"),
159  TWOPT_DOUBLE("mult", mult, "multiplier for event memory allocation"),
160  TWOPT_DOUBLE("lookahead", lookahead, "lookahead for events"),
161  TWOPT_UINT("start-events", g_phold_start_events, "number of initial messages per LP"),
162  TWOPT_UINT("stagger", stagger, "Set to 1 to stagger event uniformly across 0 to end time."),
163  TWOPT_UINT("memory", optimistic_memory, "additional memory buffers"),
164  TWOPT_CHAR("run", run_id, "user supplied run name"),
165  TWOPT_END()
166 };
167 
168 int
169 main(int argc, char **argv)
170 {
171 
172 #ifdef TEST_COMM_ROSS
173  // Init outside of ROSS
174  MPI_Init(&argc, &argv);
175  // Split COMM_WORLD in half even/odd
176  int mpi_rank;
177  MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
178  MPI_Comm split_comm;
179  MPI_Comm_split(MPI_COMM_WORLD, mpi_rank%2, mpi_rank, &split_comm);
180  if(mpi_rank%2 == 1){
181  // tests should catch any MPI_COMM_WORLD collectives
182  MPI_Finalize();
183  }
184  // Allows ROSS to function as normal
185  tw_comm_set(split_comm);
186 #endif
187 
188  unsigned int i;
189 
190  // set a min lookahead of 1.0
191  lookahead = 1.0;
192  tw_opt_add(app_opt);
193  tw_init(&argc, &argv);
194 
195 #ifdef USE_DAMARIS
196  if(g_st_ross_rank)
197  { // only ross ranks should run code between here and tw_run()
198 #endif
199  if( lookahead > 1.0 )
200  tw_error(TW_LOC, "Lookahead > 1.0 .. needs to be less\n");
201 
202  //reset mean based on lookahead
203  mean = mean - lookahead;
204 
207  g_tw_events_per_pe = (mult * nlp_per_pe * g_phold_start_events) +
209  //g_tw_rng_default = TW_FALSE;
211 
212  tw_define_lps(nlp_per_pe, sizeof(phold_message));
213 
214  for(i = 0; i < g_tw_nlp; i++)
215  {
216  tw_lp_settype(i, &mylps[0]);
217  st_model_settype(i, &model_types[0]);
218  }
219 
220  if( g_tw_mynode == 0 )
221  {
222  printf("========================================\n");
223  printf("PHOLD Model Configuration..............\n");
224  printf(" Lookahead..............%lf\n", lookahead);
225  printf(" Start-events...........%u\n", g_phold_start_events);
226  printf(" stagger................%u\n", stagger);
227  printf(" Mean...................%lf\n", mean);
228  printf(" Mult...................%lf\n", mult);
229  printf(" Memory.................%u\n", optimistic_memory);
230  printf(" Remote.................%lf\n", percent_remote);
231  printf("========================================\n\n");
232  }
233 
234  tw_run();
235 #ifdef USE_DAMARIS
236  } // end if(g_st_ross_rank)
237 #endif
238  tw_end();
239 
240  return 0;
241 }
static unsigned int nlp_per_pe
Definition: phold.h:32
void phold_event_handler_rc(phold_state *s, tw_bf *bf, phold_message *m, tw_lp *lp)
Definition: phold.c:86
#define TW_LOC
Definition: ross-extern.h:164
double tw_stime
Definition: ross.h:150
static int g_phold_start_events
Definition: phold.h:33
double g_tw_ts_end
Definition: ross-global.c:68
void tw_error(const char *file, int line, const char *fmt,...) NORETURN
Definition: tw-util.c:74
#define TWOPT_CHAR(n, v, h)
Definition: tw-opts.h:33
static tw_stime mean
Definition: phold.h:37
static unsigned int ttl_lps
Definition: phold.h:31
void phold_commit(phold_state *s, tw_bf *bf, phold_message *m, tw_lp *lp)
Definition: phold.c:97
tw_peid phold_map(tw_lpid gid)
Definition: phold.c:5
void phold_stats_collect(phold_state *s, tw_lp *lp, char *buffer)
Definition: phold.c:134
void tw_comm_set(MPI_Comm comm)
Setup the MPI_COMM_ROSS communicator to use instead of MPI_COMM_WORLD.
Definition: network-mpi.c:59
#define TWOPT_DOUBLE(n, v, h)
Definition: tw-opts.h:32
void phold_pre_run(phold_state *s, tw_lp *lp)
Definition: phold.c:39
static tw_stime mult
Definition: phold.h:29
void phold_event_handler(phold_state *s, tw_bf *bf, phold_message *m, tw_lp *lp)
Definition: phold.c:59
void(* event_f)(void *sv, tw_bf *cv, void *msg, tw_lp *me)
Definition: ross-types.h:77
tw_lpid g_tw_nlp
Definition: ross-global.c:23
unsigned int tw_nnodes(void)
Definition: network-mpi.c:103
unsigned int c1
Definition: ross-types.h:180
int main(int argc, char **argv)
Definition: phold.c:169
void(* ev_trace_f)(void *msg, tw_lp *lp, char *buffer, int *collect_flag)
tw_stime lookahead
Definition: phold.h:26
void tw_lp_settype(tw_lpid lp, tw_lptype *type)
Definition: tw-lp.c:38
uint64_t tw_lpid
Definition: ross.h:160
Function Pointers for ROSS Event Handlers.
Definition: ross-types.h:87
static unsigned int offset_lpid
Definition: phold.h:28
tw_peid(* map_f)(tw_lpid)
Definition: ross-types.h:73
tw_lpid gid
global LP id
Definition: ross-types.h:306
static unsigned int stagger
Definition: phold.h:27
const tw_optdef app_opt[]
Definition: phold.c:153
long tw_rand_integer(tw_rng_stream *g, long low, long high)
Definition: ross-random.c:21
void tw_run(void)
Definition: tw-setup.c:339
void phold_init(phold_state *s, tw_lp *lp)
Definition: phold.c:11
tw_peid g_tw_mynode
Definition: ross-global.c:88
Reverse Computation Bitfield.
Definition: ross-types.h:178
#define TWOPT_UINT(n, v, h)
Definition: tw-opts.h:30
void(* init_f)(void *sv, tw_lp *me)
Definition: ross-types.h:72
#define TWOPT_END()
Definition: tw-opts.h:35
static int optimistic_memory
Definition: phold.h:34
void tw_opt_add(const tw_optdef *options)
Definition: tw-opts.c:14
void st_model_settype(tw_lpid i, st_model_types *model_types)
Definition: st-model-data.c:25
void(* revent_f)(void *sv, tw_bf *cv, void *msg, tw_lp *me)
Definition: ross-types.h:78
#define tw_rand_unif(G)
Definition: ross-random.h:5
void(* pre_run_f)(void *sv, tw_lp *me)
Definition: ross-types.h:76
void tw_init(int *argc, char ***argv)
Definition: tw-setup.c:33
#define tw_rand_reverse_unif(G)
Definition: ross-random.h:6
tw_lptype mylps[]
Definition: phold.c:112
unsigned long tw_peid
Definition: ross.h:147
#define TWOPT_GROUP(h)
Definition: tw-opts.h:27
double tw_rand_exponential(tw_rng_stream *g, double Lambda)
Definition: ross-random.c:69
void tw_end(void)
Definition: tw-setup.c:420
void tw_event_send(tw_event *event)
Definition: tw-event.c:9
static tw_stime percent_remote
Definition: phold.h:30
tw_rng_stream * rng
RNG stream array for this LP.
Definition: ross-types.h:317
void(* model_stat_f)(void *sv, tw_lp *lp, char *buffer)
static char run_id[1024]
Definition: phold.h:39
void event_trace(phold_message *m, tw_lp *lp, char *buffer, int *collect_flag)
Definition: phold.c:125
void(* final_f)(void *sv, tw_lp *me)
Definition: ross-types.h:80
st_model_types model_types[]
Definition: phold.c:142
double g_tw_lookahead
Definition: ross-global.c:49
void(* commit_f)(void *sv, tw_bf *cv, void *msg, tw_lp *me)
Definition: ross-types.h:79
void tw_define_lps(tw_lpid nlp, size_t msg_sz)
Definition: tw-setup.c:218
static tw_event * tw_event_new(tw_lpid dest_gid, tw_stime offset_ts, tw_lp *sender)
Definition: ross-inline.h:40
unsigned int g_tw_events_per_pe
Definition: ross-global.c:76
LP State Structure.
Definition: ross-types.h:304
void phold_finish(phold_state *s, tw_lp *lp)
Definition: phold.c:106