-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodel_main.c
92 lines (72 loc) · 1.97 KB
/
model_main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//The C main file for a ROSS model
//This file includes:
// - definition of the LP types
// - command line argument setup
// - a main function
//includes
#include "ross.h"
#include "model.h"
// Define LP types
// these are the functions called by ROSS for each LP
// multiple sets can be defined (for multiple LP types)
tw_lptype model_lps[] = {
{
(init_f) model_init,
(pre_run_f) NULL,
(event_f) model_event,
(revent_f) model_event_reverse,
(commit_f) NULL,
(final_f) model_final,
(map_f) model_map,
sizeof(state)
},
{ 0 },
};
//Define command line arguments default values
unsigned int setting_1 = 0;
//add your command line opts
const tw_optdef model_opts[] = {
TWOPT_GROUP("ROSS Model"),
TWOPT_UINT("setting_1", setting_1, "first setting for this model"),
TWOPT_END(),
};
//for doxygen
#define model_main main
int model_main (int argc, char* argv[]) {
int i;
int num_lps_per_pe;
tw_opt_add(model_opts);
tw_init(&argc, &argv);
//Do some error checking?
//Print out some settings?
//Custom Mapping
/*
g_tw_mapping = CUSTOM;
g_tw_custom_initial_mapping = &model_custom_mapping;
g_tw_custom_lp_global_to_local_map = &model_mapping_to_lp;
*/
//Useful ROSS variables and functions
// tw_nnodes() : number of nodes/processors defined
// g_tw_mynode : my node/processor id (mpi rank)
//Useful ROSS variables (set from command line)
// g_tw_events_per_pe
// g_tw_lookahead
// g_tw_nlp
// g_tw_nkp
// g_tw_synchronization_protocol
//assume 1 lp per node
num_lps_per_pe = 1;
//set up LPs within ROSS
tw_define_lps(num_lps_per_pe, sizeof(message));
// note that g_tw_nlp gets set here by tw_define_lps
// IF there are multiple LP types
// you should define the mapping of GID -> lptype index
//g_tw_lp_typemap = &model_typemap;
// set the global variable and initialize each LP's type
g_tw_lp_types = model_lps;
tw_lp_setup_types();
// Do some file I/O here? on a per-node (not per-LP) basis
tw_run();
tw_end();
return 0;
}