ROSS
st-event-trace.c
Go to the documentation of this file.
1 #include <ross.h>
2 
3 int g_st_ev_trace = 0;
4 
5 static short evtype_warned = 0;
6 
7 // collect src LP, dest LP, virtual time stamp, real time start
8 // model can implement callback function to collect model level data, e.g. event type
9 void st_collect_event_data(tw_event *cev, double recv_rt)
10 {
11  tw_clock start_cycle_time = tw_clock_read();
12  int collect_flag = 1;
13  st_event_data ev_data;
14  ev_data.src_lp = (unsigned int) cev->send_lp;
15  ev_data.dest_lp = (unsigned int) cev->dest_lp->gid;
16  ev_data.send_vts = (float) TW_STIME_DBL(cev->send_ts);
17  ev_data.recv_vts = (float) TW_STIME_DBL(cev->recv_ts);
18  ev_data.real_ts = (float) recv_rt;
19  int total_sz = sizeof(ev_data);
20 
22  {
23  fprintf(stderr, "WARNING: node: %ld: %s:%i: ", g_tw_mynode, __FILE__, __LINE__);
24  fprintf(stderr, "The struct st_model_types has not been defined! No model level data will be collected\n");
25  evtype_warned = 1;
26  }
27 
28  if (cev->dest_lp->model_types && cev->dest_lp->model_types->ev_trace)
29  ev_data.model_data_sz = cev->dest_lp->model_types->ev_sz;
30  else
31  ev_data.model_data_sz = 0;
32 
33 
34  total_sz += ev_data.model_data_sz;
35  char buffer[total_sz];
36 
37  if (ev_data.model_data_sz > 0)
38  (*cev->dest_lp->model_types->ev_trace)(tw_event_data(cev), cev->dest_lp, &buffer[sizeof(ev_data)], &collect_flag);
39 
40  if (collect_flag)
41  {
42  memcpy(&buffer[0], &ev_data, sizeof(ev_data));
44  st_buffer_push(EV_TRACE, &buffer[0], total_sz);
46  fwrite(buffer, total_sz, 1, seq_ev_trace);
47 
48  }
49  g_tw_pe->stats.s_stat_comp += tw_clock_read() - start_cycle_time;
50 }
tw_synch g_tw_synchronization_protocol
Definition: ross-global.c:18
tw_lp * dest_lp
Destination LP ID.
Definition: ross-types.h:280
size_t ev_sz
size of data collected from model for each event
tw_statistics stats
per PE counters
Definition: ross-types.h:415
tw_stime recv_ts
Actual time to be received.
Definition: ross-types.h:282
unsigned int src_lp
void st_buffer_push(int type, char *data, int size)
static tw_clock tw_clock_read(void)
Definition: aarch64.h:6
void st_collect_event_data(tw_event *cev, double recv_rt)
Definition: st-event-trace.c:9
tw_clock s_stat_comp
Definition: ross-types.h:151
Event Stucture.
Definition: ross-types.h:250
tw_lpid gid
global LP id
Definition: ross-types.h:306
static void * tw_event_data(tw_event *event)
tw_lpid send_lp
sending LP ID for data collection uses
Definition: ross-types.h:285
tw_peid g_tw_mynode
Definition: ross-global.c:88
tw_peid g_tw_masternode
Definition: ross-global.c:89
FILE * seq_ev_trace
struct st_model_types * model_types
Definition: ross-types.h:322
tw_pe * g_tw_pe
Definition: ross-global.c:75
tw_stime send_ts
Definition: ross-types.h:287
uint64_t tw_clock
Definition: aarch64.h:4
ev_trace_f ev_trace
function pointer to collect data about all events for given LP
int g_st_ev_trace
Definition: st-event-trace.c:3
static short evtype_warned
Definition: st-event-trace.c:5
int g_st_disable_out
unsigned int dest_lp
#define TW_STIME_DBL(x)
Definition: ross.h:153
unsigned int model_data_sz