Commit 34fea051 authored by Misbah Mubarak's avatar Misbah Mubarak
Browse files

allowing direct connections for non-minimal routes alone

parent 7f0c5265
......@@ -263,7 +263,7 @@ struct terminal_state
long finished_chunks;
long finished_packets;
tw_stime * last_buf_full;
tw_stime last_buf_full;
tw_stime busy_time;
tw_stime max_latency;
......@@ -338,7 +338,7 @@ struct router_state
tw_stime* next_output_available_time;
tw_stime* cur_hist_start_time;
tw_stime** last_buf_full;
tw_stime* last_buf_full;
tw_stime* busy_time;
tw_stime* busy_time_sample;
......@@ -973,11 +973,10 @@ terminal_custom_init( terminal_state * s,
rc_stack_create(&s->st);
s->num_vcs = 1;
s->vc_occupancy = (int*)calloc(s->num_vcs, sizeof(int));
s->last_buf_full = (tw_stime*)calloc(s->num_vcs, sizeof(tw_stime));
s->last_buf_full = 0.0;
for( i = 0; i < s->num_vcs; i++ )
{
s->last_buf_full[i] = 0.0;
s->vc_occupancy[i]=0;
}
......@@ -1054,7 +1053,7 @@ void router_custom_setup(router_state * r, tw_lp * lp)
r->queued_msgs_tail =
(terminal_custom_message_list***)calloc(p->radix, sizeof(terminal_custom_message_list**));
r->queued_count = (int*)calloc(p->radix, sizeof(int));
r->last_buf_full = (tw_stime**)calloc(p->radix, sizeof(tw_stime*));
r->last_buf_full = (tw_stime*)calloc(p->radix, sizeof(tw_stime*));
r->busy_time = (tw_stime*)calloc(p->radix, sizeof(tw_stime));
r->busy_time_sample = (tw_stime*)calloc(p->radix, sizeof(tw_stime));
......@@ -1079,7 +1078,7 @@ void router_custom_setup(router_state * r, tw_lp * lp)
r->vc_occupancy[i] = (int*)calloc(p->num_vcs, sizeof(int));
r->pending_msgs[i] = (terminal_custom_message_list**)calloc(p->num_vcs,
sizeof(terminal_custom_message_list*));
r->last_buf_full[i] = (tw_stime*)calloc(p->num_vcs, sizeof(tw_stime));
r->last_buf_full[i] = 0.0;
r->pending_msgs_tail[i] = (terminal_custom_message_list**)calloc(p->num_vcs,
sizeof(terminal_custom_message_list*));
r->queued_msgs[i] = (terminal_custom_message_list**)calloc(p->num_vcs,
......@@ -1087,7 +1086,6 @@ void router_custom_setup(router_state * r, tw_lp * lp)
r->queued_msgs_tail[i] = (terminal_custom_message_list**)calloc(p->num_vcs,
sizeof(terminal_custom_message_list*));
for(int j = 0; j < p->num_vcs; j++) {
r->last_buf_full[i][j] = 0.0;
r->vc_occupancy[i][j] = 0;
r->pending_msgs[i][j] = NULL;
r->pending_msgs_tail[i][j] = NULL;
......@@ -1242,10 +1240,6 @@ static void packet_generate_rc(terminal_state * s, tw_bf * bf, terminal_custom_m
}
if(bf->c11) {
s->issueIdle = 0;
if(bf->c8)
{
s->last_buf_full[0] = msg->saved_busy_time;
}
}
struct mn_stats* stat;
stat = model_net_find_stats(msg->category, s->dragonfly_stats_array);
......@@ -1333,14 +1327,6 @@ static void packet_generate(terminal_state * s, tw_bf * bf, terminal_custom_mess
} else {
bf->c11 = 1;
s->issueIdle = 1;
if(s->last_buf_full[0] == 0.0)
{
bf->c8 = 1;
msg->saved_busy_time = s->last_buf_full[0];
/* TODO: Assumes a single vc from terminal to router */
s->last_buf_full[0] = tw_now(lp);
}
}
if(s->in_send_loop == 0) {
......@@ -1371,11 +1357,13 @@ static void packet_generate(terminal_state * s, tw_bf * bf, terminal_custom_mess
static void packet_send_rc(terminal_state * s, tw_bf * bf, terminal_custom_message * msg,
tw_lp * lp)
{
if(bf->c10)
s->last_buf_full[0] = msg->saved_busy_time;
if(bf->c1) {
s->in_send_loop = 1;
if(bf->c3)
{
s->last_buf_full = msg->saved_busy_time;
}
return;
}
......@@ -1405,7 +1393,7 @@ static void packet_send_rc(terminal_state * s, tw_bf * bf, terminal_custom_messa
if(bf->c6)
{
s->busy_time = msg->saved_total_time;
s->last_buf_full[0] = msg->saved_busy_time;
s->last_buf_full = msg->saved_busy_time;
s->busy_time_sample = msg->saved_sample_time;
}
}
......@@ -1421,21 +1409,21 @@ static void packet_send(terminal_state * s, tw_bf * bf, terminal_custom_message
tw_lpid router_id;
terminal_custom_message_list* cur_entry = s->terminal_msgs[0];
bool noEmptyVC = false;
if(s->vc_occupancy[0] + s->params->chunk_size > s->params->cn_vc_size)
{
if(s->last_buf_full[0] == 0.0)
{
bf->c10 = 1;
msg->saved_busy_time = s->last_buf_full[0];
s->last_buf_full[0] = tw_now(lp);
}
}
noEmptyVC = true;
if(s->vc_occupancy[0] + s->params->chunk_size > s->params->cn_vc_size
|| cur_entry == NULL) {
bf->c1 = 1;
s->in_send_loop = 0;
if(noEmptyVC && !s->last_buf_full)
{
bf->c3 = 1;
msg->saved_busy_time = s->last_buf_full;
s->last_buf_full = tw_now(lp);
}
return;
}
......@@ -1525,16 +1513,16 @@ static void packet_send(terminal_state * s, tw_bf * bf, terminal_custom_message
ts += tw_rand_unif(lp->rng);
model_net_method_idle_event(ts, 0, lp);
if(s->last_buf_full[0] > 0.0)
if(s->last_buf_full > 0.0)
{
bf->c6 = 1;
msg->saved_total_time = s->busy_time;
msg->saved_busy_time = s->last_buf_full[0];
msg->saved_busy_time = s->last_buf_full;
msg->saved_sample_time = s->busy_time_sample;
s->busy_time += (tw_now(lp) - s->last_buf_full[0]);
s->busy_time_sample += (tw_now(lp) - s->last_buf_full[0]);
s->last_buf_full[0] = 0.0;
s->busy_time += (tw_now(lp) - s->last_buf_full);
s->busy_time_sample += (tw_now(lp) - s->last_buf_full);
s->last_buf_full = 0.0;
}
}
return;
......@@ -2379,7 +2367,8 @@ get_next_stop(router_state * s,
terminal_custom_message * msg,
int dest_router_id,
int adap_chan,
int do_chan_selection)
int do_chan_selection,
int get_direct_con)
{
int dest_lp;
tw_lpid router_dest_id;
......@@ -2424,16 +2413,9 @@ get_next_stop(router_state * s,
{
if(adap_chan >= 0)
select_chan = adap_chan;
/*if(interGroupLinks[s->router_id][dest_group_id].size() > 1)
{
bf->c19 = 1;
select_chan = tw_rand_integer(lp->rng, 0, interGroupLinks[s->router_id][dest_group_id].size() - 1);
bLink link = interGroupLinks[s->router_id][dest_group_id][select_chan];
dest_lp = link.dest;
}*/
else
else
{
if(interGroupLinks[s->router_id][dest_group_id].size() > 1)
if(interGroupLinks[s->router_id][dest_group_id].size() > 1 && get_direct_con)
select_chan = find_chan(s->router_id, dest_group_id, s->params->num_routers);
else
{
......@@ -2944,10 +2926,6 @@ static void router_packet_receive_rc(router_state * s,
}
}
if(bf->c4) {
if(bf->c22)
{
s->last_buf_full[output_port][output_chan] = msg->saved_busy_time;
}
delete_terminal_custom_message_list(return_tail(s->queued_msgs[output_port],
s->queued_msgs_tail[output_port], output_chan));
s->queued_count[output_port] -= s->params->chunk_size;
......@@ -2981,12 +2959,12 @@ router_packet_receive( router_state * s,
cur_chunk->msg.path_type = routing; /*defaults to the routing algorithm if we
don't have adaptive or progressive adaptive routing here*/
// printf("\n Packet %llu source %d arrived at router %d ", msg->packet_ID, msg->src_terminal_id, s->router_id);
/* Set the default route as minimal for prog-adaptive */
if((routing == PROG_ADAPTIVE || routing == ADAPTIVE) && cur_chunk->msg.last_hop == TERMINAL)
cur_chunk->msg.path_type = MINIMAL;
/* for prog-adaptive routing, record the current route of packet */
int get_direct_con = 0;
prev_path_type = cur_chunk->msg.path_type;
/* Here we check for local or global adaptive routing. If destination router
......@@ -3092,14 +3070,15 @@ router_packet_receive( router_state * s,
}
}
if(cur_chunk->msg.path_type == NON_MINIMAL && (cur_chunk->msg.my_l_hop == 1 || cur_chunk->msg.my_l_hop == 2))
get_direct_con = 1;
/* If the packet route has just changed to non-minimal with prog-adaptive
* routing, we have to compute the next stop based on that */
int do_chan_selection = 0;
if(routing == PROG_ADAPTIVE && prev_path_type != next_path_type && s->group_id == src_grp_id)
{
do_chan_selection = 1;
}
next_stop = get_next_stop(s, lp, bf, &(cur_chunk->msg), dest_router_id, adap_chan, do_chan_selection);
next_stop = get_next_stop(s, lp, bf, &(cur_chunk->msg), dest_router_id, adap_chan, do_chan_selection, get_direct_con);
if(cur_chunk->msg.packet_ID == LLU(TRACK_PKT) && cur_chunk->msg.src_terminal_id == T_ID)
printf("\n Packet %llu arrived at router %u next stop %d final stop %d local hops %d global hops %d", cur_chunk->msg.packet_ID, s->router_id, next_stop, dest_router_id, cur_chunk->msg.my_l_hop, cur_chunk->msg.my_g_hop);
......@@ -3192,17 +3171,6 @@ router_packet_receive( router_state * s,
append_to_terminal_custom_message_list( s->queued_msgs[output_port],
s->queued_msgs_tail[output_port], output_chan, cur_chunk);
s->queued_count[output_port] += s->params->chunk_size;
/* a check for pending msgs is non-empty then we dont set anything. If
* that is empty then we check if last_buf_full is set or not. If already
* set then we don't overwrite it. If two packets arrive next to each other
* then the first person should be setting it. */
if(s->pending_msgs[output_port][output_chan] == NULL && s->last_buf_full[output_port][output_chan] == 0.0)
{
bf->c22 = 1;
msg->saved_busy_time = s->last_buf_full[output_port][output_chan];
s->last_buf_full[output_port][output_chan] = tw_now(lp);
}
}
msg->saved_vc = output_port;
......@@ -3221,8 +3189,17 @@ static void router_packet_send_rc(router_state * s,
int output_chan = msg->saved_channel;
if(bf->c1) {
s->in_send_loop[output_port] = 1;
if(bf->c2) {
s->last_buf_full[output_port] = msg->saved_busy_time;
}
return;
}
if(bf->c8)
{
s->busy_time[output_port] = msg->saved_rcv_time;
s->busy_time_sample[output_port] = msg->saved_sample_time;
s->last_buf_full[output_port] = msg->saved_busy_time;
}
tw_rand_reverse_unif(lp->rng);
......@@ -3284,9 +3261,26 @@ router_packet_send( router_state * s,
if(cur_entry == NULL) {
bf->c1 = 1;
s->in_send_loop[output_port] = 0;
if(s->queued_count[output_port] && !s->last_buf_full[output_port])
{
bf->c2 = 1;
msg->saved_busy_time = s->last_buf_full[output_port];
s->last_buf_full[output_port] = tw_now(lp);
}
return;
}
if(s->last_buf_full[output_port])
{
bf->c8 = 1;
msg->saved_rcv_time = s->busy_time[output_port];
msg->saved_busy_time = s->last_buf_full[output_port];
msg->saved_sample_time = s->busy_time_sample[output_port];
s->busy_time[output_port] += (tw_now(lp) - s->last_buf_full[output_port]);
s->busy_time_sample[output_port] += (tw_now(lp) - s->last_buf_full[output_port]);
s->last_buf_full[output_port] = 0.0;
}
int to_terminal = 1, global = 0;
double delay = s->params->cn_delay;
double bandwidth = s->params->cn_bandwidth;
......@@ -3418,12 +3412,6 @@ static void router_buf_update_rc(router_state * s,
int indx = msg->vc_index;
int output_chan = msg->output_chan;
s->vc_occupancy[indx][output_chan] += s->params->chunk_size;
if(bf->c3)
{
s->busy_time[indx] = msg->saved_rcv_time;
s->busy_time_sample[indx] = msg->saved_sample_time;
s->last_buf_full[indx][output_chan] = msg->saved_busy_time;
}
if(bf->c1) {
terminal_custom_message_list* head = return_tail(s->pending_msgs[indx],
s->pending_msgs_tail[indx], output_chan);
......@@ -3445,16 +3433,6 @@ static void router_buf_update(router_state * s, tw_bf * bf, terminal_custom_mess
int output_chan = msg->output_chan;
s->vc_occupancy[indx][output_chan] -= s->params->chunk_size;
if(s->last_buf_full[indx][output_chan] > 0.0)
{
bf->c3 = 1;
msg->saved_rcv_time = s->busy_time[indx];
msg->saved_busy_time = s->last_buf_full[indx][output_chan];
msg->saved_sample_time = s->busy_time_sample[indx];
s->busy_time[indx] += (tw_now(lp) - s->last_buf_full[indx][output_chan]);
s->busy_time_sample[indx] += (tw_now(lp) - s->last_buf_full[indx][output_chan]);
s->last_buf_full[indx][output_chan] = 0.0;
}
if(s->queued_msgs[indx][output_chan] != NULL) {
bf->c1 = 1;
terminal_custom_message_list *head = return_head(s->queued_msgs[indx],
......
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