Commit 075727c7 authored by Caitlin Ross's avatar Caitlin Ross

fixing bug in virtual time sampling for models that don't need it

parent 92ea64e4
...@@ -146,10 +146,13 @@ void mn_event_collect(model_net_wrap_msg *m, tw_lp *lp, char *buffer, int *colle ...@@ -146,10 +146,13 @@ void mn_event_collect(model_net_wrap_msg *m, tw_lp *lp, char *buffer, int *colle
break; break;
case MN_BASE_PASS: case MN_BASE_PASS:
sub_msg = ((char*)m)+msg_offsets[((model_net_base_state*)lp->cur_state)->net_id]; sub_msg = ((char*)m)+msg_offsets[((model_net_base_state*)lp->cur_state)->net_id];
if (g_st_ev_trace == RB_TRACE || g_st_ev_trace == COMMIT_TRACE) if (((model_net_base_state*)lp->cur_state)->sub_model_type)
(((model_net_base_state*)lp->cur_state)->sub_model_type->rbev_trace)(sub_msg, lp, buffer, collect_flag); {
else if (g_st_ev_trace == FULL_TRACE) if (g_st_ev_trace == RB_TRACE || g_st_ev_trace == COMMIT_TRACE)
(((model_net_base_state*)lp->cur_state)->sub_model_type->ev_trace)(sub_msg, lp, buffer, collect_flag); (((model_net_base_state*)lp->cur_state)->sub_model_type->rbev_trace)(sub_msg, lp, buffer, collect_flag);
else if (g_st_ev_trace == FULL_TRACE)
(((model_net_base_state*)lp->cur_state)->sub_model_type->ev_trace)(sub_msg, lp, buffer, collect_flag);
}
break; break;
default: // this shouldn't happen, but can help detect an issue default: // this shouldn't happen, but can help detect an issue
type = 9004; type = 9004;
...@@ -160,18 +163,21 @@ void mn_event_collect(model_net_wrap_msg *m, tw_lp *lp, char *buffer, int *colle ...@@ -160,18 +163,21 @@ void mn_event_collect(model_net_wrap_msg *m, tw_lp *lp, char *buffer, int *colle
void mn_model_stat_collect(model_net_base_state *s, tw_lp *lp, char *buffer) void mn_model_stat_collect(model_net_base_state *s, tw_lp *lp, char *buffer)
{ {
// need to call the model level stats collection fn // need to call the model level stats collection fn
(*s->sub_model_type->model_stat_fn)(s->sub_state, lp, buffer); if (s->sub_model_type)
(*s->sub_model_type->model_stat_fn)(s->sub_state, lp, buffer);
return; return;
} }
void mn_sample_event(model_net_base_state *s, tw_bf * bf, tw_lp * lp, void *sample) void mn_sample_event(model_net_base_state *s, tw_bf * bf, tw_lp * lp, void *sample)
{ {
(*s->sub_model_type->sample_event_fn)(s->sub_state, bf, lp, sample); if (s->sub_model_type)
(*s->sub_model_type->sample_event_fn)(s->sub_state, bf, lp, sample);
} }
void mn_sample_rc_event(model_net_base_state *s, tw_bf * bf, tw_lp * lp, void *sample) void mn_sample_rc_event(model_net_base_state *s, tw_bf * bf, tw_lp * lp, void *sample)
{ {
(*s->sub_model_type->sample_revent_fn)(s->sub_state, bf, lp, sample); if (s->sub_model_type)
(*s->sub_model_type->sample_revent_fn)(s->sub_state, bf, lp, sample);
} }
st_model_types mn_model_types[MAX_NETS]; st_model_types mn_model_types[MAX_NETS];
...@@ -228,12 +234,13 @@ void model_net_base_register(int *do_config_nets){ ...@@ -228,12 +234,13 @@ void model_net_base_register(int *do_config_nets){
method_array[i]->mn_register(&model_net_base_lp); method_array[i]->mn_register(&model_net_base_lp);
if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps) // for ROSS event tracing if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps) // for ROSS event tracing
{ {
memcpy(&mn_model_types[i], &mn_model_base_type, sizeof(st_model_types)); if (method_array[i]->mn_model_stat_register != NULL)
// st_model_type_register(model_net_lp_config_names[i], &mn_model_types[i]);
if (method_array[i]->mn_model_stat_register == NULL) //else
st_model_type_register(model_net_lp_config_names[i], &mn_model_types[i]); {
else memcpy(&mn_model_types[i], &mn_model_base_type, sizeof(st_model_types));
method_array[i]->mn_model_stat_register(&mn_model_types[i]); method_array[i]->mn_model_stat_register(&mn_model_types[i]);
}
} }
} }
} }
...@@ -481,8 +488,11 @@ void model_net_base_lp_init( ...@@ -481,8 +488,11 @@ void model_net_base_lp_init(
if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps) if (g_st_ev_trace || g_st_model_stats || g_st_use_analysis_lps)
{ {
ns->sub_model_type = model_net_get_model_stat_type(ns->net_id); ns->sub_model_type = model_net_get_model_stat_type(ns->net_id);
mn_model_types[ns->net_id].mstat_sz = ns->sub_model_type->mstat_sz; if (ns->sub_model_type)
mn_model_types[ns->net_id].sample_struct_sz = ns->sub_model_type->sample_struct_sz; {
mn_model_types[ns->net_id].mstat_sz = ns->sub_model_type->mstat_sz;
mn_model_types[ns->net_id].sample_struct_sz = ns->sub_model_type->sample_struct_sz;
}
} }
// NOTE: some models actually expect LP state to be 0 initialized... // NOTE: some models actually expect LP state to be 0 initialized...
......
...@@ -629,7 +629,10 @@ const tw_lptype* model_net_get_lp_type(int net_id) ...@@ -629,7 +629,10 @@ const tw_lptype* model_net_get_lp_type(int net_id)
const st_model_types* model_net_get_model_stat_type(int net_id) const st_model_types* model_net_get_model_stat_type(int net_id)
{ {
return method_array[net_id]->mn_get_model_stat_types(); if (method_array[net_id]->mn_get_model_stat_types)
return method_array[net_id]->mn_get_model_stat_types();
else
return NULL;
} }
void model_net_report_stats(int net_id) void model_net_report_stats(int net_id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment