Commit 77e85ef9 authored by Caitlin Ross's avatar Caitlin Ross

changes related to the ROSS model-level sampling feature

parent 1bc73715
......@@ -21,8 +21,8 @@ const tw_lptype* lp_type_lookup(const char* name);
/* register an LP with CODES/ROSS */
void lp_type_register(const char* name, const tw_lptype* type);
void trace_type_register(const char* name, const st_trace_type* type);
const st_trace_type* trace_type_lookup(const char* name);
void st_model_type_register(const char* name, const st_model_types* type);
const st_model_types* st_model_type_lookup(const char* name);
#ifdef __cplusplus
}
#endif
......
......@@ -63,8 +63,8 @@ struct model_net_method
revent_f mn_sample_rc_fn;
init_f mn_sample_init_fn;
final_f mn_sample_fini_fn;
void (*mn_trace_register)(st_trace_type *base_type);
const st_trace_type* (*mn_get_trace_type)();
void (*mn_model_stat_register)(st_model_types *base_type);
const st_model_types* (*mn_get_model_stat_types)();
};
extern struct model_net_method * method_array[];
......
......@@ -388,7 +388,7 @@ void model_net_set_msg_param(
/* returns pointer to LP information for simplenet module */
const tw_lptype* model_net_get_lp_type(int net_id);
const st_trace_type* model_net_get_trace_type(int net_id);
const st_model_types* model_net_get_model_stat_type(int net_id);
DEPRECATED
uint64_t model_net_get_packet_size(int net_id);
......
......@@ -91,6 +91,8 @@ struct terminal_message
tw_stime saved_hist_start_time;
tw_stime saved_sample_time;
tw_stime msg_start_time;
tw_stime saved_busy_time_ross;
tw_stime saved_fin_chunks_ross;
int saved_hist_num;
int saved_occupancy;
......
......@@ -1569,22 +1569,29 @@ void nw_lp_event_collect(nw_message *m, tw_lp *lp, char *buffer, int *collect_fl
memcpy(buffer, &type, sizeof(type));
}
st_trace_type nw_lp_trace_types[] = {
void nw_lp_model_stat_collect(nw_state *s, tw_lp *lp, char *buffer)
{
return;
}
st_model_types nw_lp_model_types[] = {
{(rbev_trace_f) nw_lp_event_collect,
sizeof(int),
(ev_trace_f) nw_lp_event_collect,
sizeof(int)},
sizeof(int),
(model_stat_f) nw_lp_model_stat_collect,
0},
{0}
};
static const st_trace_type *nw_lp_get_trace_types(void)
static const st_model_types *nw_lp_get_model_stat_types(void)
{
return(&nw_lp_trace_types[0]);
return(&nw_lp_model_types[0]);
}
void nw_lp_register_trace()
void nw_lp_register_model()
{
trace_type_register("nw-lp", nw_lp_get_trace_types());
st_model_type_register("nw-lp", nw_lp_get_model_stat_types());
}
/* end of ROSS event tracing setup */
......@@ -1659,8 +1666,8 @@ int main( int argc, char** argv )
nw_add_lp_type();
model_net_register();
if (g_st_ev_trace)
nw_lp_register_trace();
if (g_st_ev_trace || g_st_model_stats)
nw_lp_register_model();
net_ids = model_net_configure(&num_nets);
// assert(num_nets == 1);
......
......@@ -130,22 +130,29 @@ void ft_svr_event_collect(svr_msg *m, tw_lp *lp, char *buffer, int *collect_flag
memcpy(buffer, &type, sizeof(type));
}
st_trace_type ft_svr_trace_types[] = {
void ft_svr_model_stat_collect(svr_state *s, tw_lp *lp, char *buffer)
{
return;
}
st_model_types ft_svr_model_types[] = {
{(rbev_trace_f) ft_svr_event_collect,
sizeof(int),
(ev_trace_f) ft_svr_event_collect,
sizeof(int)},
sizeof(int),
(model_stat_f) ft_svr_model_stat_collect,
0},
{0}
};
static const st_trace_type *ft_svr_get_trace_types(void)
static const st_model_types *ft_svr_get_model_stat_types(void)
{
return(&ft_svr_trace_types[0]);
return(&ft_svr_model_types[0]);
}
void ft_svr_register_trace()
void ft_svr_register_model_stats()
{
trace_type_register("server", ft_svr_get_trace_types());
st_model_type_register("server", ft_svr_get_model_stat_types());
}
const tw_optdef app_opt [] =
......@@ -437,7 +444,7 @@ int main(
svr_add_lp_type();
if (g_st_ev_trace)
ft_svr_register_trace();
ft_svr_register_model_stats();
codes_mapping_setup();
......
......@@ -116,22 +116,29 @@ void svr_event_collect(svr_msg *m, tw_lp *lp, char *buffer, int *collect_flag)
memcpy(buffer, &type, sizeof(type));
}
st_trace_type svr_trace_types[] = {
void svr_model_stat_collect(svr_state *s, tw_lp *lp, char *buffer)
{
return;
}
st_model_types svr_model_types[] = {
{(rbev_trace_f) svr_event_collect,
sizeof(int),
(ev_trace_f) svr_event_collect,
sizeof(int)},
sizeof(int),
(model_stat_f) svr_model_stat_collect,
0},
{0}
};
static const st_trace_type *svr_get_trace_types(void)
static const st_model_types *svr_get_model_stat_types(void)
{
return(&svr_trace_types[0]);
return(&svr_model_types[0]);
}
void svr_register_trace()
void svr_register_model_types()
{
trace_type_register("server", svr_get_trace_types());
st_model_type_register("server", svr_get_model_stat_types());
}
const tw_optdef app_opt [] =
......@@ -393,8 +400,8 @@ int main(
model_net_register();
svr_add_lp_type();
if (g_st_ev_trace)
svr_register_trace();
if (g_st_ev_trace || g_st_model_stats)
svr_register_model_types();
codes_mapping_setup();
......
This diff is collapsed.
......@@ -1811,6 +1811,7 @@ void switch_packet_receive_rc(switch_state * s,
s_arrive_r++;
#endif
int output_port = msg->saved_vc;
tw_rand_reverse_unif(lp->rng);
if(bf->c1)
{
tw_rand_reverse_unif(lp->rng);
......@@ -2636,10 +2637,13 @@ int ft_get_output_port( switch_state * s, tw_bf * bf, fattree_message * msg,
assert(end_port > start_port);
outport = start_port;
//outport = start_port;
// when occupancy is same, just choose random port
outport = tw_rand_integer(lp->rng, start_port, end_port-1);
int load = s->vc_occupancy[outport] + s->queued_length[outport];
if(load != 0) {
for(int port = start_port + 1; port < end_port; port++) {
//for(int port = start_port + 1; port < end_port; port++) {
for(int port = start_port; port < end_port; port++) {
if(s->vc_occupancy[port] + s->queued_length[port] < load) {
load = s->vc_occupancy[port] + s->queued_length[port];
outport = port;
......@@ -2968,23 +2972,27 @@ void fattree_event_collect(fattree_message *m, tw_lp *lp, char *buffer, int *col
memcpy(buffer, &type, sizeof(type));
}
st_trace_type fattree_trace_types[] = {
// TODO will need to separate fattree_method into one for terminal and one for switch
// in order to use the ROSS model stats collection
st_model_types fattree_model_types[] = {
{(rbev_trace_f) fattree_event_collect,
sizeof(int),
(ev_trace_f) fattree_event_collect,
sizeof(int)},
sizeof(int),
NULL,
0},
{0}
};
static const st_trace_type *fattree_get_trace_types(void)
static const st_model_types *fattree_get_model_stat_types(void)
{
return(&fattree_trace_types[0]);
return(&fattree_model_types[0]);
}
static void fattree_register_trace(st_trace_type *base_type)
static void fattree_register_model_stats(st_model_types *base_type)
{
trace_type_register(LP_CONFIG_NM, base_type);
trace_type_register("fattree_switch", &fattree_trace_types[0]);
st_model_type_register(LP_CONFIG_NM, base_type);
st_model_type_register("fattree_switch", &fattree_model_types[0]);
//trace_type_register("fattree_switch", base_type);
}
/*** END of ROSS event tracing additions */
......@@ -3018,7 +3026,7 @@ struct model_net_method fattree_method =
// .model_net_method_find_local_device = NULL,
.mn_collective_call = NULL,
.mn_collective_call_rc = NULL,
.mn_trace_register = fattree_register_trace,
.mn_get_trace_type = fattree_get_trace_types
.mn_model_stat_register = fattree_register_model_stats,
.mn_get_model_stat_types = fattree_get_model_stat_types
};
......@@ -53,7 +53,7 @@ typedef struct model_net_base_state {
// lp type and state of underlying model net method - cache here so we
// don't have to constantly look up
const tw_lptype *sub_type;
const st_trace_type *sub_trace_type;
const st_model_types *sub_model_type;
void *sub_state;
} model_net_base_state;
......@@ -139,10 +139,10 @@ void mn_event_collect(model_net_wrap_msg *m, tw_lp *lp, char *buffer, int *colle
break;
case MN_BASE_PASS:
sub_msg = ((char*)m)+msg_offsets[((model_net_base_state*)lp->cur_state)->net_id];
if (g_st_ev_trace == RB_TRACE)
(((model_net_base_state*)lp->cur_state)->sub_trace_type->rbev_trace)(sub_msg, lp, buffer, collect_flag);
if (g_st_ev_trace == RB_TRACE || g_st_ev_trace == COMMIT_TRACE)
(((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_trace_type->ev_trace)(sub_msg, lp, buffer, collect_flag);
(((model_net_base_state*)lp->cur_state)->sub_model_type->ev_trace)(sub_msg, lp, buffer, collect_flag);
break;
default: // this shouldn't happen, but can help detect an issue
type = 9004;
......@@ -150,11 +150,22 @@ void mn_event_collect(model_net_wrap_msg *m, tw_lp *lp, char *buffer, int *colle
}
}
st_trace_type mn_trace_types = {
void mn_model_stat_collect(model_net_base_state *s, tw_lp *lp, char *buffer)
{
// need to call the model level stats collection fn
(*s->sub_model_type->model_stat_fn)(s->sub_state, lp, buffer);
return;
}
st_model_types mn_model_types[MAX_NETS];
st_model_types mn_model_base_type = {
(rbev_trace_f) mn_event_collect,
sizeof(int),
(ev_trace_f) mn_event_collect,
sizeof(int),
(model_stat_f) mn_model_stat_collect,
0
};
/**** END LP, EVENT PROCESSING FUNCTION DECLS ****/
......@@ -195,12 +206,14 @@ void model_net_base_register(int *do_config_nets){
&model_net_base_lp);
else
method_array[i]->mn_register(&model_net_base_lp);
if (g_st_ev_trace) // for ROSS event tracing
if (g_st_ev_trace || g_st_model_stats) // for ROSS event tracing
{
if (method_array[i]->mn_trace_register == NULL)
trace_type_register(model_net_lp_config_names[i], &mn_trace_types);
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]);
else
method_array[i]->mn_trace_register(&mn_trace_types);
method_array[i]->mn_model_stat_register(&mn_model_types[i]);
}
}
}
......@@ -404,8 +417,12 @@ void model_net_base_lp_init(
ns->sub_type = model_net_get_lp_type(ns->net_id);
if (g_st_ev_trace)
ns->sub_trace_type = model_net_get_trace_type(ns->net_id);
/* some ROSS instrumentation setup */
if (g_st_ev_trace || g_st_model_stats)
{
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;
}
// NOTE: some models actually expect LP state to be 0 initialized...
// *cough anything that uses mn_stats_array cough*
......
......@@ -597,9 +597,9 @@ const tw_lptype* model_net_get_lp_type(int net_id)
return method_array[net_id]->mn_get_lp_type();
}
const st_trace_type* model_net_get_trace_type(int net_id)
const st_model_types* model_net_get_model_stat_type(int net_id)
{
return method_array[net_id]->mn_get_trace_type();
return method_array[net_id]->mn_get_model_stat_types();
}
void model_net_report_stats(int net_id)
......
......@@ -458,7 +458,7 @@ static void codes_mapping_init(void)
tw_lpid nkp_per_pe = g_tw_nkp;
tw_lpid lpid, kpid;
const tw_lptype *lptype;
const st_trace_type *trace_type;
const st_model_types *trace_type;
/* have 16 kps per pe, this is the optimized configuration for ROSS custom mapping */
for(kpid = 0; kpid < nkp_per_pe; kpid++)
......@@ -489,10 +489,10 @@ static void codes_mapping_init(void)
else
/* sorry, const... */
tw_lp_settype(ross_lid, (tw_lptype*) lptype);
if (g_st_ev_trace)
if (g_st_ev_trace || g_st_model_stats)
{
trace_type = trace_type_lookup(lp_type_name);
st_evtrace_settype(ross_lid, (st_trace_type*) trace_type);
trace_type = st_model_type_lookup(lp_type_name);
st_model_settype(ross_lid, (st_model_types*) trace_type);
}
}
return;
......
......@@ -16,7 +16,7 @@ struct lp_name_mapping
{
const char* name;
const tw_lptype* type;
const st_trace_type* trace_type;
const st_model_types* trace_type;
};
static struct lp_name_mapping map_array[MAX_LP_TYPES];
......@@ -48,7 +48,7 @@ const tw_lptype* lp_type_lookup(const char* name)
}
// needs to be called after lp_type_register()
void trace_type_register(const char* name, const st_trace_type* type)
void st_model_type_register(const char* name, const st_model_types* type)
{
int i;
......@@ -61,7 +61,7 @@ void trace_type_register(const char* name, const st_trace_type* type)
}
}
const st_trace_type* trace_type_lookup(const char* name)
const st_model_types* st_model_type_lookup(const char* name)
{
int i;
......
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