ROSS
core
instrumentation
st-model-data.c
Go to the documentation of this file.
1
#include <ross.h>
2
3
st_model_types
*
g_st_model_types
= NULL;
4
static
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
10
void
st_model_setup_types
(
tw_lp
*lp)
11
{
12
if
(
g_st_model_types
)
13
lp->
model_types
= &
g_st_model_types
[
g_tw_lp_typemap
(lp->
gid
)];
14
else
if
(!
model_type_warned
&&
g_tw_mynode
==
g_tw_masternode
)
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"
);
18
model_type_warned
= 1;
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
25
void
st_model_settype
(
tw_lpid
i,
st_model_types
*
model_types
)
26
{
27
if
(
model_types
)
28
{
29
tw_lp
*lp =
g_tw_lp
[i];
30
lp->
model_types
=
model_types
;
31
}
32
else
if
(!
model_type_warned
&&
g_tw_mynode
==
g_tw_masternode
)
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"
);
36
model_type_warned
= 1;
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
*/
45
void
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
90
if
(
g_tw_synchronization_protocol
!=
SEQUENTIAL
)
91
st_buffer_push
(
MODEL_COL
, &buffer[0], total_sz);
92
else
if
(
g_tw_synchronization_protocol
==
SEQUENTIAL
&& !
g_st_disable_out
)
93
fwrite(buffer, total_sz, 1,
seq_model
);
94
}
95
}
96
pe
->stats.s_stat_comp +=
tw_clock_read
() - start_cycle_time;
97
}
pe
tw_pe * pe
Definition
avl_tree.c:10
tw_clock_read
static tw_clock tw_clock_read(void)
Definition
aarch64.h:8
tw_clock
uint64_t tw_clock
Definition
aarch64.h:6
MODEL_TYPE
@ MODEL_TYPE
Definition
st-instrumentation.h:53
MODEL_COL
@ MODEL_COL
Definition
st-instrumentation.h:45
st_buffer_push
void st_buffer_push(int type, char *data, int size)
Definition
st-stats-buffer.c:112
seq_model
FILE * seq_model
Definition
st-instrumentation.h:29
g_st_disable_out
int g_st_disable_out
Definition
st-instrumentation.c:9
g_st_model_types
st_model_types * g_st_model_types
Definition
st-model-data.c:3
TW_STIME_DBL
#define TW_STIME_DBL(x)
Definition
ross-base.h:42
tw_lpid
uint64_t tw_lpid
Definition
ross-base.h:49
g_tw_lp_typemap
tw_typemap_f g_tw_lp_typemap
Definition
ross-global.c:106
g_tw_lp
tw_lp ** g_tw_lp
Definition
ross-global.c:28
g_tw_mynode
tw_peid g_tw_mynode
Definition
ross-global.c:92
g_tw_nlp
tw_lpid g_tw_nlp
Definition
ross-global.c:24
g_tw_masternode
tw_peid g_tw_masternode
Definition
ross-global.c:93
g_tw_synchronization_protocol
tw_synch g_tw_synchronization_protocol
Definition
ross-global.c:19
tw_now
static tw_stime tw_now(tw_lp const *lp)
Definition
ross-kernel-inline.h:84
SEQUENTIAL
@ SEQUENTIAL
Definition
ross-types.h:37
model_types
st_model_types model_types[]
Definition
phold.main.c:142
st_model_settype
void st_model_settype(tw_lpid i, st_model_types *model_types)
Definition
st-model-data.c:25
model_type_warned
static int model_type_warned
Definition
st-model-data.c:4
st_model_setup_types
void st_model_setup_types(tw_lp *lp)
Definition
st-model-data.c:10
st_collect_model_data
void st_collect_model_data(tw_pe *pe, double current_rt, int stats_type)
Definition
st-model-data.c:45
model_metadata
Definition
st-instrumentation.h:239
model_metadata::kpid
unsigned int kpid
Definition
st-instrumentation.h:241
model_metadata::peid
unsigned int peid
Definition
st-instrumentation.h:240
model_metadata::gvt
float gvt
Definition
st-instrumentation.h:243
model_metadata::lpid
unsigned int lpid
Definition
st-instrumentation.h:242
model_metadata::stats_type
int stats_type
Definition
st-instrumentation.h:244
model_metadata::model_sz
unsigned int model_sz
Definition
st-instrumentation.h:245
sample_metadata
Definition
st-instrumentation.h:64
sample_metadata::ts
tw_stime ts
Definition
st-instrumentation.h:67
sample_metadata::real_time
double real_time
Definition
st-instrumentation.h:68
sample_metadata::flag
int flag
Definition
st-instrumentation.h:65
sample_metadata::sample_sz
int sample_sz
Definition
st-instrumentation.h:66
st_model_types
Definition
st-instrumentation.h:221
st_model_types::mstat_sz
size_t mstat_sz
size of data collected from model at sampling points
Definition
st-instrumentation.h:225
st_model_types::model_stat_fn
model_stat_f model_stat_fn
function pointer to collect model level data for RT and GVT-based instrumentation
Definition
st-instrumentation.h:224
tw_kp::id
tw_kpid id
ID number, otherwise its not available to the app.
Definition
ross-types.h:378
tw_lp
LP State Structure.
Definition
ross-types.h:336
tw_lp::model_types
struct st_model_types * model_types
Definition
ross-types.h:355
tw_lp::kp
tw_kp * kp
kp – Kernel process that we belong to (must match pe).
Definition
ross-types.h:345
tw_lp::gid
tw_lpid gid
global LP id
Definition
ross-types.h:338
tw_lp::cur_state
void * cur_state
Current application LP data.
Definition
ross-types.h:347
tw_pe
Holds the entire PE state.
Definition
ross-types.h:416
Generated by
1.14.0