From 902c79387e30f0d661e175480a7088c8613cb03a Mon Sep 17 00:00:00 2001 From: Neil McGlohon Date: Fri, 6 Apr 2018 18:15:49 -0400 Subject: [PATCH] Dragonfly Plus Model: Local Adaptive Routing Now Considers All Min Paths --- src/networks/model-net/dragonfly-plus.C | 52 ++++++++++++++++++------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/src/networks/model-net/dragonfly-plus.C b/src/networks/model-net/dragonfly-plus.C index cc0ee1c..5b6f81c 100644 --- a/src/networks/model-net/dragonfly-plus.C +++ b/src/networks/model-net/dragonfly-plus.C @@ -2287,7 +2287,7 @@ static int get_min_hops_to_dest_from_conn(router_state *s, tw_bf *bf, terminal_p } } else { //next is not in final destination group - if (next_hops_type == SPINE) + if (next_hops_type == SPINE) return 3; //Next Spine -> Spine -> Leaf -> dest_term else { assert(next_hops_type == LEAF); @@ -2406,25 +2406,38 @@ static Connection do_dfp_routing(router_state *s, if (msg->dfp_upward_channel_flag == 1 || (my_group_id == fdest_group_id)) choose_minimal = true; //in both of these cases minimal should always be chosen + vector< Connection > selected_minimal_conns; + if (my_group_id == fdest_group_id) { //if we are in the final destination group + selected_minimal_conns = poss_min_next_stops; //then we want to find the least congested out of all of the possible minimum paths + + //two garbage random numbers to keep things even since we're not randomly selecting two connections. + //TODO This will need to be changed if select_two is made configurable + tw_rand_integer(lp->rng,0,1); + tw_rand_integer(lp->rng,0,1); + } + else //then we do the typical randomly select two connections + { + selected_minimal_conns = dfp_select_two_connections(s, bf, msg, lp, poss_min_next_stops); + } - vector< Connection > two_minimal_conns = dfp_select_two_connections(s, bf, msg, lp, poss_min_next_stops); - vector< Connection > two_nonminimal_conns = dfp_select_two_connections(s, bf, msg, lp, poss_non_min_next_stops); - int num_conns = two_minimal_conns.size() + two_nonminimal_conns.size(); //we selected two from each //TODO maybe make this configurable + vector< Connection > selected_nonminimal_conns = dfp_select_two_connections(s, bf, msg, lp, poss_non_min_next_stops); + + int num_conns = selected_minimal_conns.size() + selected_nonminimal_conns.size(); //we selected two from each //TODO maybe make this configurable //calculate the best connections for minimal and nonminimal int scores[num_conns]; for(int i = 0; i < num_conns; i++) { - if(i < (two_minimal_conns.size()) ) - scores[i] = dfp_score_connection(s, bf, msg, lp, two_minimal_conns[i]); + if(i < (selected_minimal_conns.size()) ) + scores[i] = dfp_score_connection(s, bf, msg, lp, selected_minimal_conns[i]); else - scores[i] = dfp_score_connection(s, bf, msg, lp, two_nonminimal_conns[i-two_minimal_conns.size()]); + scores[i] = dfp_score_connection(s, bf, msg, lp, selected_nonminimal_conns[i-selected_minimal_conns.size()]); } int best_min_score = INT_MAX; int best_min_score_index = 0; - for(int i = 0; i < two_minimal_conns.size(); i++) + for(int i = 0; i < selected_minimal_conns.size(); i++) { if (scores[i] < best_min_score) { best_min_score = scores[i]; @@ -2434,11 +2447,11 @@ static Connection do_dfp_routing(router_state *s, int best_non_min_score = INT_MAX; int best_non_min_score_index = 0; - for(int i = two_minimal_conns.size(); i < num_conns; i++) + for(int i = selected_minimal_conns.size(); i < num_conns; i++) { if (scores[i] < best_non_min_score) { best_non_min_score = scores[i]; - best_non_min_score_index = i-two_minimal_conns.size(); + best_non_min_score_index = i-selected_minimal_conns.size(); } } //end score calculation @@ -2461,11 +2474,11 @@ static Connection do_dfp_routing(router_state *s, } if (choose_minimal) { - theConn = two_minimal_conns[best_min_score_index]; + theConn = selected_minimal_conns[best_min_score_index]; } else { msg->path_type = NON_MINIMAL; //We chose a nonminimal stop - we will never reset the path type back to minimal!!!! - theConn = two_nonminimal_conns[best_non_min_score_index]; + theConn = selected_nonminimal_conns[best_non_min_score_index]; } } @@ -2604,8 +2617,6 @@ static void router_packet_receive(router_state *s, tw_bf *bf, terminal_plus_mess cur_chunk->msg.vc_index = output_port; cur_chunk->msg.next_stop = next_stop; - int max_vc_size = s->params->cn_vc_size; - output_chan = 0; if(cur_chunk->msg.dfp_upward_channel_flag) { @@ -2615,6 +2626,19 @@ static void router_packet_receive(router_state *s, tw_bf *bf, terminal_plus_mess output_chan = 0; } + ConnectionType port_type = s->connMan->get_port_type(output_port); + int max_vc_size = 0; + if (port_type == CONN_GLOBAL) { + max_vc_size = s->params->global_vc_size; + } + else if (port_type == CONN_LOCAL) { + max_vc_size = s->params->local_vc_size; + } + else { + assert(port_type == CONN_TERMINAL); + max_vc_size = s->params->cn_vc_size; + } + cur_chunk->msg.output_chan = output_chan; cur_chunk->msg.my_N_hop++; -- 2.26.2