ROSS
st-model-data.c
Go to the documentation of this file.
1#include <ross.h>
2
4static int model_type_warned = 0;
5
6
7// if model uses tw_lp_setup_types() to set lp->type, it will also call
8// this function to set up the functions types for model-level data collection
9// because this can make use of the already defined type mapping
11{
15 {
16 fprintf(stderr, "WARNING: node: %ld: %s:%i: ", g_tw_mynode, __FILE__, __LINE__);
17 fprintf(stderr, "The g_st_model_types has not been defined! No model level data will be collected\n");
19 }
20
21}
22
23// if model uses tw_lp_settypes(), model will also need to call
24// this function to set up function types for model-level data collection
26{
27 if (model_types)
28 {
29 tw_lp *lp = g_tw_lp[i];
31 }
33 {
34 fprintf(stderr, "WARNING: node: %ld: %s:%i: ", g_tw_mynode, __FILE__, __LINE__);
35 fprintf(stderr, "The struct st_model_types has not been defined for at least 1 LP type! No model level data will be collected for LP types without a valid st_model_types struct defined.\n");
37 }
38}
39
40/*
41 * This function allows for ROSS to collect model level data, when not using Analysis LPs.
42 * Call this function when collecting simulation level data (GVT-based and/or real time-based).
43 * Loop through all LPs on this PE and collect stats
44 */
45void st_collect_model_data(tw_pe *pe, double current_rt, int stats_type)
46{
47 tw_clock start_cycle_time = tw_clock_read();
48 int index;
49 tw_lpid lpid = 0;
50 int total_sz = 0;
51 tw_lp *clp;
52 sample_metadata sample_md;
53 model_metadata model_md;
54 sample_md.flag = MODEL_TYPE;
55 sample_md.sample_sz = sizeof(model_md);
56 sample_md.real_time = current_rt;
57 model_md.peid = (unsigned int) g_tw_mynode;
58#ifdef USE_RAND_TIEBREAKER
59 model_md.gvt = (float) TW_STIME_DBL(pe->GVT_sig.recv_ts);
60#else
61 model_md.gvt = (float) TW_STIME_DBL(pe->GVT);
62#endif
63 model_md.stats_type = stats_type;
64
65 for (lpid = 0; lpid < g_tw_nlp; lpid++)
66 {
67 index = 0;
68 clp = g_tw_lp[lpid];
69 if (!clp->model_types || !clp->model_types->model_stat_fn)
70 {
71 // may not want to collect model stats on every LP type, so if not defined, just continue
72 continue;
73 }
74
75 sample_md.ts = tw_now(clp);
76 model_md.kpid = (unsigned int) clp->kp->id;
77 model_md.lpid = (unsigned int) clp->gid;
78 model_md.model_sz = (unsigned int) clp->model_types->mstat_sz;
79 total_sz = sizeof(sample_md) + sizeof(model_md) + model_md.model_sz;
80 char buffer[total_sz];
81 memcpy(&buffer[0], &sample_md, sizeof(sample_md));
82 index += sizeof(sample_md);
83 memcpy(&buffer[index], &model_md, sizeof(model_md));
84 index += sizeof(model_md);
85
86 if (model_md.model_sz > 0)
87 {
88 (*clp->model_types->model_stat_fn)(clp->cur_state, clp, &buffer[index]);
89
91 st_buffer_push(MODEL_COL, &buffer[0], total_sz);
93 fwrite(buffer, total_sz, 1, seq_model);
94 }
95 }
96 pe->stats.s_stat_comp += tw_clock_read() - start_cycle_time;
97}
tw_pe * pe
Definition avl_tree.c:10
static tw_clock tw_clock_read(void)
Definition aarch64.h:8
uint64_t tw_clock
Definition aarch64.h:6
@ MODEL_TYPE
@ MODEL_COL
void st_buffer_push(int type, char *data, int size)
FILE * seq_model
int g_st_disable_out
st_model_types * g_st_model_types
#define TW_STIME_DBL(x)
Definition ross-base.h:42
uint64_t tw_lpid
Definition ross-base.h:49
tw_typemap_f g_tw_lp_typemap
tw_lp ** g_tw_lp
Definition ross-global.c:28
tw_peid g_tw_mynode
Definition ross-global.c:92
tw_lpid g_tw_nlp
Definition ross-global.c:24
tw_peid g_tw_masternode
Definition ross-global.c:93
tw_synch g_tw_synchronization_protocol
Definition ross-global.c:19
static tw_stime tw_now(tw_lp const *lp)
@ SEQUENTIAL
Definition ross-types.h:37
st_model_types model_types[]
Definition phold.main.c:142
void st_model_settype(tw_lpid i, st_model_types *model_types)
static int model_type_warned
void st_model_setup_types(tw_lp *lp)
void st_collect_model_data(tw_pe *pe, double current_rt, int stats_type)
unsigned int model_sz
size_t mstat_sz
size of data collected from model at sampling points
model_stat_f model_stat_fn
function pointer to collect model level data for RT and GVT-based instrumentation
tw_kpid id
ID number, otherwise its not available to the app.
Definition ross-types.h:378
LP State Structure.
Definition ross-types.h:336
struct st_model_types * model_types
Definition ross-types.h:355
tw_kp * kp
kp – Kernel process that we belong to (must match pe).
Definition ross-types.h:345
tw_lpid gid
global LP id
Definition ross-types.h:338
void * cur_state
Current application LP data.
Definition ross-types.h:347
Holds the entire PE state.
Definition ross-types.h:416