Commit b2a2fdfe authored by Neil McGlohon's avatar Neil McGlohon

Merge branch 'dfp-online-workloads-broken' into 'dfp-online-workloads'

Dfp online workloads broken

See merge request neil/codes!10
parents 7068b1f5 84b7e9fb
...@@ -55,8 +55,8 @@ PARAMS ...@@ -55,8 +55,8 @@ PARAMS
inter-group-connections="../src/network-workloads/conf/dragonfly-plus/dfp-test-inter"; inter-group-connections="../src/network-workloads/conf/dragonfly-plus/dfp-test-inter";
# routing protocol to be used # routing protocol to be used
# routing="minimal"; # routing="minimal";
routing="prog-adaptive"; routing="non-minimal-leaf";
# route scoring protocol to be used - options are 'alpha' or 'beta' # route scoring protocol to be used - options are 'alpha' or 'beta'
route_scoring_metric="beta"; route_scoring_metric="alpha";
} }
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#endif #endif
#define DUMP_CONNECTIONS 0 #define DUMP_CONNECTIONS 0
#define PRINT_CONFIG 1
#define CREDIT_SIZE 8 #define CREDIT_SIZE 8
#define DFLY_HASH_TABLE_SIZE 4999 #define DFLY_HASH_TABLE_SIZE 4999
#define SHOW_ADAPTIVE_STATS 1 #define SHOW_ADAPTIVE_STATS 1
...@@ -325,6 +326,17 @@ typedef enum conn_minimality_t ...@@ -325,6 +326,17 @@ typedef enum conn_minimality_t
C_NONMIN C_NONMIN
} conn_minimality_t; } conn_minimality_t;
typedef enum dfp_path_hop_t
{
SOURCE_LEAF = 1, //a leaf router in the packets originating group
SOURCE_SPINE, //a spine router in the packets originating group
INTERMEDIATE_LEAF, //a leaf router not in the packets originating group or destination group
INTERMEDIATE_SPINE, //a spine router not in the packets originating group or destination group
DESTINATION_LEAF, //a leaf router in the packets destination group
DESTINATION_SPINE, //a spine router in the packets destination group
FINAL_DESTINATION //the leaf router that has a connection to the destination terminal
} dfp_path_hop_t;
typedef enum routing_alg_t typedef enum routing_alg_t
{ {
MINIMAL = 1, //will always follow the minimal route from host to host MINIMAL = 1, //will always follow the minimal route from host to host
...@@ -566,6 +578,43 @@ static terminal_plus_message_list *return_tail(terminal_plus_message_list **this ...@@ -566,6 +578,43 @@ static terminal_plus_message_list *return_tail(terminal_plus_message_list **this
return tail; return tail;
} }
void dragonfly_plus_print_params(dragonfly_plus_param *p)
{
int myRank;
MPI_Comm_rank(MPI_COMM_CODES, &myRank);
if (!myRank) {
printf("--------- Dragonfly Plus Parameters ---------\n");
printf("num_routers = %d\n",p->num_routers);
printf("local_bandwidth = %.2f\n",p->local_bandwidth);
printf("global_bandwidth = %.2f\n",p->global_bandwidth);
printf("cn_bandwidth = %.2f\n",p->cn_bandwidth);
printf("num_vcs = %d\n",p->num_vcs);
printf("local_vc_size = %d\n",p->local_vc_size);
printf("global_vc_size = %d\n",p->global_vc_size);
printf("cn_vc_size = %d\n",p->cn_vc_size);
printf("num_cn = %d\n",p->num_cn);
printf("intra_grp_radix = %d\n",p->intra_grp_radix);
printf("num_level_chans = %d\n",p->num_level_chans);
printf("num_router_spine = %d\n",p->num_router_spine);
printf("num_router_leaf = %d\n",p->num_router_leaf);
printf("adaptive_threshold = %d\n",p->adaptive_threshold);
printf("max_port_score = %d\n",p->max_port_score);
printf("num_groups = %d\n",p->num_groups);
printf("radix = %d\n",p->radix);
printf("total_routers = %d\n",p->total_routers);
printf("total_terminals = %d\n",p->total_terminals);
printf("num_global_connections = %d\n",p->num_global_connections);
printf("cn_delay = %.2f\n",p->cn_delay);
printf("local_delay = %.2f\n",p->local_delay);
printf("global_delay = %.2f\n",p->global_delay);
printf("credit_delay = %.2f\n",p->credit_delay);
printf("router_delay = %.2f\n",p->router_delay);
printf("scoring = %d\n",scoring);
printf("routing = %d\n",routing);
printf("---------------------------------------------\n");
}
}
static void dragonfly_read_config(const char *anno, dragonfly_plus_param *params) static void dragonfly_read_config(const char *anno, dragonfly_plus_param *params)
{ {
/*Adding init for router magic number*/ /*Adding init for router magic number*/
...@@ -816,6 +865,24 @@ static void dragonfly_read_config(const char *anno, dragonfly_plus_param *params ...@@ -816,6 +865,24 @@ static void dragonfly_read_config(const char *anno, dragonfly_plus_param *params
} }
} }
if (DUMP_CONNECTIONS)
{
if (!myRank) {
for(int i=0; i < connManagerList.size(); i++)
{
connManagerList[i].print_connections();
}
}
printf("Does spine 479 have conn to group 27?\n");
for(int i = 0; i < connectionList[479/p->num_routers][27].size(); i++)
{
printf("%d\n",connectionList[479/p->num_routers][27][i]);
}
}
// exit(1);
if (!myRank) { if (!myRank) {
printf("\n Total nodes %d routers %d groups %d routers per group %d radix %d\n", printf("\n Total nodes %d routers %d groups %d routers per group %d radix %d\n",
p->num_cn * p->num_router_leaf * p->num_groups, p->total_routers, p->num_groups, p->num_routers, p->radix); p->num_cn * p->num_router_leaf * p->num_groups, p->total_routers, p->num_groups, p->num_routers, p->radix);
...@@ -825,6 +892,9 @@ static void dragonfly_read_config(const char *anno, dragonfly_plus_param *params ...@@ -825,6 +892,9 @@ static void dragonfly_read_config(const char *anno, dragonfly_plus_param *params
p->local_delay = bytes_to_ns(p->chunk_size, p->local_bandwidth); p->local_delay = bytes_to_ns(p->chunk_size, p->local_bandwidth);
p->global_delay = bytes_to_ns(p->chunk_size, p->global_bandwidth); p->global_delay = bytes_to_ns(p->chunk_size, p->global_bandwidth);
p->credit_delay = bytes_to_ns(CREDIT_SIZE, p->local_bandwidth); // assume 8 bytes packet p->credit_delay = bytes_to_ns(CREDIT_SIZE, p->local_bandwidth); // assume 8 bytes packet
if (PRINT_CONFIG)
dragonfly_plus_print_params(p);
} }
void dragonfly_plus_configure() void dragonfly_plus_configure()
...@@ -883,10 +953,10 @@ void dragonfly_plus_report_stats() ...@@ -883,10 +953,10 @@ void dragonfly_plus_report_stats()
max_time / 1000, (float) final_msg_sz / total_finished_msgs, total_finished_msgs, max_time / 1000, (float) final_msg_sz / total_finished_msgs, total_finished_msgs,
total_finished_chunks); total_finished_chunks);
if(isRoutingAdaptive(routing) || SHOW_ADAPTIVE_STATS) { if(isRoutingAdaptive(routing) || SHOW_ADAPTIVE_STATS) {
printf("\n ADAPTIVE ROUTING STATS: %d chunks routed minimally %d chunks routed non-minimally completed packets %lld \n", printf("\n ADAPTIVE ROUTING STATS: %d chunks routed minimally %d chunks routed non-minimally - completed packets: %lld \n",
total_minimal_packets, total_nonmin_packets, total_finished_chunks); total_minimal_packets, total_nonmin_packets, total_finished_chunks);
} }
printf("\n Total packets generated %ld finished %ld Locally routed- same router %ld different-router %ld Remote (inter-group) %ld \n", total_gen, total_fin, total_local_packets_sr, total_local_packets_sg, total_remote_packets); printf("\n Total packets generated: %ld; finished: %ld; Locally routed: same router: %ld, different-router: %ld; Remote (inter-group): %ld \n", total_gen, total_fin, total_local_packets_sr, total_local_packets_sg, total_remote_packets);
} }
return; return;
} }
...@@ -1279,8 +1349,8 @@ static void packet_generate(terminal_state *s, tw_bf *bf, terminal_plus_message ...@@ -1279,8 +1349,8 @@ static void packet_generate(terminal_state *s, tw_bf *bf, terminal_plus_message
double cn_delay = s->params->cn_delay; double cn_delay = s->params->cn_delay;
int dest_router_id = dragonfly_plus_get_assigned_router_id(msg->dfp_dest_terminal_id, s->params); int dest_router_id = dragonfly_plus_get_assigned_router_id(msg->dfp_dest_terminal_id, s->params);
int dest_grp_id = dest_router_id / s->params->num_routers; int dest_grp_id = dest_router_id / s->params->num_routers;
int src_grp_id = s->router_id / s->params->num_routers; int src_grp_id = s->router_id / s->params->num_routers;
if(src_grp_id == dest_grp_id) if(src_grp_id == dest_grp_id)
{ {
...@@ -1650,7 +1720,23 @@ static void packet_arrive(terminal_state *s, tw_bf *bf, terminal_plus_message *m ...@@ -1650,7 +1720,23 @@ static void packet_arrive(terminal_state *s, tw_bf *bf, terminal_plus_message *m
// NIC aggregation - should this be a separate function? // NIC aggregation - should this be a separate function?
// Trigger an event on receiving server // Trigger an event on receiving server
// printf("Packet Arrived: %d hops\n",msg->my_N_hop); if (routing == MINIMAL) {
if (msg->my_N_hop > 4)
printf("Bad Routed Packet Arrived: %d hops\n",msg->my_N_hop);
}
if (routing == NON_MINIMAL_LEAF) {
if (msg->my_N_hop > 7)
printf("Bad Routed Packet Arrived: %d hops\n",msg->my_N_hop);
}
if (routing == NON_MINIMAL_SPINE) {
if (msg->my_N_hop > 5)
printf("Bad Routed Packet Arrived: %d hops\n",msg->my_N_hop);
}
if (routing == PROG_ADAPTIVE) {
if (msg->my_N_hop > 7)
printf("Bad Routed Packet Arrived: %d hops\n",msg->my_N_hop);
}
if (!s->rank_tbl) if (!s->rank_tbl)
s->rank_tbl = qhash_init(dragonfly_rank_hash_compare, dragonfly_hash_func, DFLY_HASH_TABLE_SIZE); s->rank_tbl = qhash_init(dragonfly_rank_hash_compare, dragonfly_hash_func, DFLY_HASH_TABLE_SIZE);
...@@ -1717,6 +1803,11 @@ static void packet_arrive(terminal_state *s, tw_bf *bf, terminal_plus_message *m ...@@ -1717,6 +1803,11 @@ static void packet_arrive(terminal_state *s, tw_bf *bf, terminal_plus_message *m
/* WE do not allow self messages through dragonfly */ /* WE do not allow self messages through dragonfly */
assert(lp->gid != msg->src_terminal_id); assert(lp->gid != msg->src_terminal_id);
// Verify that the router that send the packet to this terminal is the router assigned to this terminal
int dest_router_id = dragonfly_plus_get_assigned_router_id(s->terminal_id, s->params);
int received_from_rel_id = codes_mapping_get_lp_relative_id(msg->intm_lp_id,0,0);
assert(dest_router_id == received_from_rel_id);
uint64_t num_chunks = msg->packet_size / s->params->chunk_size; uint64_t num_chunks = msg->packet_size / s->params->chunk_size;
if (msg->packet_size < s->params->chunk_size) if (msg->packet_size < s->params->chunk_size)
num_chunks++; num_chunks++;
...@@ -2234,100 +2325,265 @@ void dragonfly_plus_router_final(router_state *s, tw_lp *lp) ...@@ -2234,100 +2325,265 @@ void dragonfly_plus_router_final(router_state *s, tw_lp *lp)
lp_io_write(lp->gid, (char *) "dragonfly-plus-router-traffic", written, s->output_buf2); lp_io_write(lp->gid, (char *) "dragonfly-plus-router-traffic", written, s->output_buf2);
} }
//Returns a vector of possible next stops that follow a minimal route to the destination // //Curretnly only supports specific router if that specific router is a leaf
static vector< Connection > get_possible_minimal_next_stops(router_state *s, // //Returns a vector of ALL possible next stops that can lead to the specified router
tw_bf *bf, // static vector< Connection > get_possible_next_stops_to_specific_router(router_state *s,
terminal_plus_message *msg, // tw_bf *bf,
tw_lp *lp, // terminal_plus_message *msg,
int fdest_router_id) // tw_lp *lp,
// dfp_path_hop_t my_hop_type,
// int specific_router_id)
// {
// int local_router_id = s->router_id;
// int my_group_id = s->router_id / s->params->num_routers;
// int specific_group_id = specific_router_id / s->params->num_routers;
// vector< Connection > possible_next_conns;
// if (local_router_id == specific_router_id) { //then we're the destination router, dest terminal is connected to this router
// assert(s->dfp_router_type == LEAF);
// int term_id = msg->dfp_dest_terminal_id;
// possible_next_conns = s->connMan->get_connections_to_gid(term_id, CONN_TERMINAL);
// }
// else if (s->group_id == specific_group_id) { //then the destination router is in this group, just needs to be routed to it
// if (s->dfp_router_type == SPINE)
// possible_next_conns = s->connMan->get_connections_to_gid(specific_router_id, CONN_LOCAL);
// else {
// assert(s->dfp_router_type == LEAF);
// possible_next_conns = s->connMan->get_connections_by_type(CONN_LOCAL);
// }
// }
// else { //then the destination is in a different group
// if (s->dfp_router_type == SPINE)
// possible_next_conns = s->connMan->get_connections_to_group(specific_group_id); //gets connections to intm group
// else {
// assert(s->dfp_router_type == LEAF);
// //we need a list of spine routers in our group that can connect to the intermediate group
// set<int> poss_router_id_set;
// for(int i = 0; i < connectionList[my_group_id][specific_group_id].size(); i++)
// {
// int poss_router_id = connectionList[my_group_id][specific_group_id][i];
// if (poss_router_id_set.count(poss_router_id) == 0) { //if we haven't added the connections from poss_router_id yet
// vector< Connection > conns = s->connMan->get_connections_to_gid(poss_router_id, CONN_LOCAL);
// poss_router_id_set.insert(poss_router_id);
// possible_next_conns.insert(possible_next_conns.end(), conns.begin(), conns.end());
// }
// }
// }
// }
// return possible_next_conns;
// }
//Curretnly only supports specific router if that specific router is a leaf
//Returns a vector of ALL possible next stops that can lead to the specified router
static vector< Connection > get_possible_next_stops_to_specific_router(router_state *s,
tw_bf *bf,
terminal_plus_message *msg,
tw_lp *lp,
dfp_path_hop_t my_hop_type,
int specific_router_id)
{ {
int local_router_id = s->router_id; int local_router_id = s->router_id;
int my_group_id = s->router_id / s->params->num_routers; int my_group_id = s->router_id / s->params->num_routers;
int fdest_group_id = fdest_router_id / s->params->num_routers; int specific_group_id = specific_router_id / s->params->num_routers;
int origin_grp_id = msg->origin_router_id / s->params->num_routers;
vector< Connection > possible_next_conns = vector< Connection >(); vector< Connection > possible_next_conns;
if (fdest_router_id == local_router_id) {
assert(s->dfp_router_type == LEAF);
int term_id = msg->dfp_dest_terminal_id;
possible_next_conns = s->connMan->get_connections_to_gid(term_id, CONN_TERMINAL);
}
else if (s->group_id == fdest_group_id) { //we need to forward to the assigned router for the destination terminal
if (s->dfp_router_type == LEAF) {
//we need to send to a spine who can send it back down to the dest leaf in our group
possible_next_conns = s->connMan->get_connections_by_type(CONN_LOCAL);
}
else {
assert(s->dfp_router_type == SPINE);
int assigned_router = dragonfly_plus_get_assigned_router_id(msg->dfp_dest_terminal_id, s->params);
possible_next_conns = s->connMan->get_connections_to_gid(assigned_router, CONN_LOCAL);
}
}
else {
//Then packet direction is upward to another group
if (s->dfp_router_type == LEAF) {
//we need to get a list of connections to spine routers in our group that can connect to the fdest group
switch (my_hop_type) {
case SOURCE_LEAF :
case INTERMEDIATE_LEAF :
{
//possible minimal connections are to spines that have a connection to the dest router
set<int> poss_router_id_set; set<int> poss_router_id_set;
for(int i = 0; i < connectionList[my_group_id][fdest_group_id].size(); i++) for(int i = 0; i < connectionList[my_group_id][specific_group_id].size(); i++)
{ {
int poss_router_id = connectionList[my_group_id][fdest_group_id][i]; int poss_router_id = connectionList[my_group_id][specific_group_id][i];
if (poss_router_id_set.count(poss_router_id) == 0) { //if we haven't added the connections from poss_router_id yet if (poss_router_id_set.count(poss_router_id) == 0) { //if we haven't added the connections from poss_router_id yet
vector< Connection > conns = s->connMan->get_connections_to_gid(poss_router_id, CONN_LOCAL); vector< Connection > conns = s->connMan->get_connections_to_gid(poss_router_id, CONN_LOCAL);
possible_next_conns.insert(possible_next_conns.end(), conns.begin(), conns.end());
poss_router_id_set.insert(poss_router_id); poss_router_id_set.insert(poss_router_id);
possible_next_conns.insert(possible_next_conns.end(), conns.begin(), conns.end());
} }
} }
} } break;
else { case SOURCE_SPINE :
assert(s->dfp_router_type == SPINE); case INTERMEDIATE_SPINE :
possible_next_conns = s->connMan->get_connections_to_group(fdest_group_id); //gets connections to fdest group {
} //possible minimal connections are to spines in the destination group
possible_next_conns = s->connMan->get_connections_to_group(specific_group_id);
} break;
case DESTINATION_LEAF :
{
possible_next_conns = s->connMan->get_connections_to_gid(msg->dfp_dest_terminal_id, CONN_TERMINAL);
} break;
case DESTINATION_SPINE :
{
possible_next_conns = s->connMan->get_connections_to_gid(specific_router_id, CONN_LOCAL);
} break;
default :
tw_error(TW_LOC, "Incorrectly handled hop type\n");
} }
return possible_next_conns; return possible_next_conns;
} }
//Returns a vector of possible next stops that follow a nonminimal route -
static vector< Connection > get_possible_nonminimal_next_stops(router_state *s, // static vector< Connection > get_poss_minimal_stops_to_destination_router(router_state *s,
tw_bf *bf, // tw_bf *bf,
terminal_plus_message *msg, // terminal_plus_message *msg,
tw_lp *lp, // tw_lp *lp,
int fdest_router_id) // dfp_path_hop_t my_hop_type,
// int fdest_router_id)
// {
// int local_router_id = s->router_id;
// int my_group_id = s->router_id / s->params->num_routers;
// int dest_group_id = fdest_router_id / s->params->num_routers;
// vector< Connection > possible_next_conns;
// switch (my_hop_type) {
// case SOURCE_LEAF :
// case INTERMEDIATE_LEAF :
// {
// //possible minimal connections are to spines that have a connection to the dest router
// set<int> poss_router_id_set;
// for(int i = 0; i < connectionList[my_group_id][dest_group_id].size(); i++)
// {
// int poss_router_id = connectionList[my_group_id][dest_group_id][i];
// if (poss_router_id_set.count(poss_router_id) == 0) { //if we haven't added the connections from poss_router_id yet
// vector< Connection > conns = s->connMan->get_connections_to_gid(poss_router_id, CONN_LOCAL);
// poss_router_id_set.insert(poss_router_id);
// possible_next_conns.insert(possible_next_conns.end(), conns.begin(), conns.end());
// }
// }
// } break;
// case SOURCE_SPINE :
// case INTERMEDIATE_SPINE :
// {
// //possible minimal connections are to spines in the destination group
// possible_next_conns = s->connMan->get_connections_to_group(dest_group_id);
// } break;
// case DESTINATION_LEAF :
// {
// possible_next_conns = s->connMan->get_connections_to_gid(msg->dfp_dest_terminal_id, CONN_TERMINAL);
// } break;
// case DESTINATION_SPINE :
// {
// possible_next_conns = s->connMan->get_connections_to_gid(fdest_router_id, CONN_LOCAL);
// } break;
// default :
// tw_error(TW_LOC, "Incorrectly handled hop type\n");
// }
// return possible_next_conns;
// }
static vector< Connection > get_possible_stops_to_intermediate_router(router_state *s,
tw_bf *bf,
terminal_plus_message *msg,
tw_lp *lp,
dfp_path_hop_t my_hop_type,
int specific_router_id)
{ {
int local_router_id = s->router_id; int local_router_id = s->router_id;
int my_group_id = s->router_id / s->params->num_routers; int my_group_id = s->router_id / s->params->num_routers;
int fdest_group_id = fdest_router_id / s->params->num_routers; int specific_group_id = specific_router_id / s->params->num_routers;
int origin_grp_id = msg->origin_router_id / s->params->num_routers;
vector< Connection > possible_next_conns; vector< Connection > possible_next_conns;
if (s->group_id == fdest_group_id) { switch (my_hop_type) {
return possible_next_conns; //empty because there is only minimal connections within the destination group case SOURCE_LEAF :
{
//possible minimal connections are to spines that have a connection to the dest router
set<int> poss_router_id_set;
for(int i = 0; i < connectionList[my_group_id][specific_group_id].size(); i++)
{
int poss_router_id = connectionList[my_group_id][specific_group_id][i];
if (poss_router_id_set.count(poss_router_id) == 0) { //if we haven't added the connections from poss_router_id yet
vector< Connection > conns = s->connMan->get_connections_to_gid(poss_router_id, CONN_LOCAL);
poss_router_id_set.insert(poss_router_id);
possible_next_conns.insert(possible_next_conns.end(), conns.begin(), conns.end());
}
}
} break;
case SOURCE_SPINE :
{
//possible minimal connections are to spines in the destination group
possible_next_conns = s->connMan->get_connections_to_group(specific_group_id);
} break;
case INTERMEDIATE_SPINE :
{
possible_next_conns = s->connMan->get_connections_to_gid(specific_router_id, CONN_LOCAL);
} break;
case INTERMEDIATE_LEAF :
case DESTINATION_LEAF :
case DESTINATION_SPINE :
case FINAL_DESTINATION :
default :
tw_error(TW_LOC, "Incorrectly handled hop type\n");
} }
else {
if(s->dfp_router_type == LEAF) {
possible_next_conns = s->connMan->get_connections_by_type(CONN_LOCAL); //I am a leaf, my local connections are all to spine routers in my group
}
else { //SPINE
assert(s->dfp_router_type == SPINE);
bool in_intermediate_group = (my_group_id != origin_grp_id) && (my_group_id != fdest_group_id);
if (in_intermediate_group) { //then the nonminimal paths are those that go to leafs in my group return possible_next_conns;
possible_next_conns = s->connMan->get_connections_by_type(CONN_LOCAL); }
}
else { // Then we have to be in source group - nonminimal paths are those that go to any other group other than destination
for(int i = 0; i < s->params->num_groups; i++)
{ static vector< Connection > get_possible_minimal_stops_to_destination(router_state *s,
if (i != fdest_group_id) { tw_bf *bf,
vector< Connection > conns_to_group = s->connMan->get_connections_to_group(i); terminal_plus_message *msg,
possible_next_conns.insert(possible_next_conns.end(),conns_to_group.begin(),conns_to_group.end()); tw_lp *lp,
} dfp_path_hop_t my_hop_type,
int fdest_router_id)
{
int my_router_id = s->router_id;
int my_group_id = s->router_id / s->params->num_routers;
int dest_group_id = fdest_router_id / s->params->num_routers;
vector< Connection > possible_next_conns;
switch (my_hop_type) {
case SOURCE_LEAF :
case INTERMEDIATE_LEAF :
{
assert(s->dfp_router_type == LEAF);
//possible minimal connections are to spines that have a connection to the dest router group
set<int> poss_router_id_set;
for(int i = 0; i < connectionList[my_group_id][dest_group_id].size(); i++)
{
int poss_router_id = connectionList[my_group_id][dest_group_id][i];
// printf("%d\n",poss_router_id);
if (poss_router_id_set.count(poss_router_id) == 0) { //if we haven't added the connections from poss_router_id yet
vector< Connection > conns = s->connMan->get_connections_to_gid(poss_router_id, CONN_LOCAL);
poss_router_id_set.insert(poss_router_id);
possible_next_conns.insert(possible_next_conns.end(), conns.begin(), conns.end());
} }
} }
}
} break;
case SOURCE_SPINE :
case INTERMEDIATE_SPINE :
{
assert(s->dfp_router_type == SPINE);
//possible minimal connections are to spines in the destination group
possible_next_conns = s->connMan->get_connections_to_group(dest_group_id);
printf("%d connections from spine %d to group %d for %d\n",possible_next_conns.size(), my_router_id, dest_group_id, fdest_router_id);
} break;
case DESTINATION_LEAF :
{
possible_next_conns = s->connMan->get_connections_by_type(CONN_LOCAL);
} break;
case DESTINATION_SPINE :
{
possible_next_conns = s->connMan->get_connections_to_gid(fdest_router_id, CONN_LOCAL);
} break;
case FINAL_DESTINATION :
{
possible_next_conns = s->connMan->get_connections_to_gid(msg->dfp_dest_terminal_id, CONN_TERMINAL);
} break;
default :
tw_error(TW_LOC, "Incorrectly handled hop type\n");
} }
return possible_next_conns; return possible_next_conns;
} }
...@@ -2361,7 +2617,7 @@ static int get_min_hops_to_dest_from_conn(router_state *s, tw_bf *bf, terminal_p ...@@ -2361,7 +2617,7 @@ static int get_min_hops_to_dest_from_conn(router_state *s, tw_bf *bf, terminal_p
vector< Connection > cons_to_dest_group = connManagerList[conn.dest_gid].get_connections_to_group(fdest_group_id); vector< Connection > cons_to_dest_group = connManagerList[conn.dest_gid].get_connections_to_group(fdest_group_id);
if (cons_to_dest_group.size() == 0) if (cons_to_dest_group.size() == 0)
return 5; //Next Spine -> Leaf -> Spine -> Spine -> Leaf -> dest_term return 5; //Next Spine -> Leaf -> Spine -> Spine -> Leaf -> dest_term
else else
return 3; //Next Spine -> Spine -> Leaf -> dest_term return 3; //Next Spine -> Spine -> Leaf -> dest_term
} }
else { else {
...@@ -2380,6 +2636,13 @@ static int dfp_score_connection(router_state *s, tw_bf *bf, terminal_plus_messag ...@@ -2380,6 +2636,13 @@ static int dfp_score_connection(router_state *s, tw_bf *bf, terminal_plus_messag
int score = 0; //can't forget to initialize this to zero. int score = 0; //can't forget to initialize this to zero.
int port = conn.port; int port = conn.port;
if (port == -1) {
if (scoring_preference == LOWER)
return INT_MAX;
else
return 0;
}
switch(scoring) { switch(scoring) {
case ALPHA: //considers vc occupancy and queued count only LOWER SCORE IS BETTER case ALPHA: //considers vc occupancy and queued count only LOWER SCORE IS BETTER
{ {
...@@ -2402,7 +2665,7 @@ static int dfp_score_connection(router_state *s, tw_bf *bf, terminal_plus_messag ...@@ -2402,7 +2665,7 @@ static int dfp_score_connection(router_state *s, tw_bf *bf, terminal_plus_messag
break; break;
} }
case GAMMA: //consideres vc occupancy and queue count but ports that follow a minimal path to fdest are biased 2:1 bonus by multiplying minimal by 2 HIGHER SCORE IS BETTER case GAMMA: //consideres vc occupancy and queue count but ports that follow a minimal path to fdest are biased 2:1 bonus by multiplying minimal by 2 HIGHER SCORE IS BETTER
{ {
score = s->params->max_port_score; //initialize this to max score. score = s->params->max_port_score; //initialize this to max score.
int to_subtract = 0; int to_subtract = 0;
for(int k=0; k < s->params->num_vcs; k++) for(int k=0; k < s->params->num_vcs; k++)
...@@ -2435,6 +2698,25 @@ static int dfp_score_connection(router_state *s, tw_bf *bf, terminal_plus_messag ...@@ -2435,6 +2698,25 @@ static int dfp_score_connection(router_state *s, tw_bf *bf, terminal_plus_messag
return score; return score;
} }
//returns a router id of a leaf router in a group that is not the source or the destination groups
//Uses two RNGs
static int dfp_pick_intermediate_router(router_state *s, tw_bf *bf, terminal_plus_message *msg, tw_lp *lp, int source_group_id, int dest_group_id)
{
vector< int > other_groups;
for(int i = 0; i < s->params->num_groups; i++)
{
if ((i != source_group_id) && (i != dest_group_id))
other_groups.push_back(i);
}
int intm_group_id = other_groups[tw_rand_integer(lp->rng, 0, other_groups.size() -1 )];
int intm_loc_id = tw_rand_integer(lp->rng, 0, s->params->num_router_leaf -1);
int intm_router_id = (intm_group_id * s->params->num_routers) + intm_loc_id;
return intm_router_id;
}
static vector< Connection > dfp_select_two_connections(router_state *s, tw_bf *bf, terminal_plus_message *msg, tw_lp *lp, vector< Connection > conns) static vector< Connection > dfp_select_two_connections(router_state *s, tw_bf *bf, terminal_plus_message *msg, tw_lp *lp, vector< Connection > conns)
{ {
if(conns.size() < 2) { if(conns.size() < 2) {
...@@ -2483,6 +2765,127 @@ static vector< Connection > dfp_select_two_connections(router_state *s, tw_bf *b ...@@ -2483,6 +2765,127 @@ static vector< Connection > dfp_select_two_connections(router_state *s, tw_bf *b
return selected_conns; return selected_conns;
} }
static Connection get_best_connection_from_conns(router_state *s, tw_bf *bf, terminal_plus_message *msg, tw_lp *lp, vector<Connection> conns, conn_minimality_t minimality)
{
if (conns.size() == 0)
tw_error(TW_LOC, "get best connection from conns, conns are empty!");
if (conns.size() < 2)
return conns[0];
int num_to_compare = 2; //TODO make this a configurable
vector< Connection > selected_conns = dfp_select_two_connections(s, bf, msg, lp, conns);
int scores[num_to_compare];
for(int i = 0; i < num_to_compare; i++)
{
scores[i] = dfp_score_connection(s, bf, msg, lp, selected_conns[i], minimality);
}
int best_score_index = 0;
if (scoring_preference == LOWER) {
int best_score = INT_MAX;
for(int i = 0; i < num_to_compare; i++)
{
if (scores[i] < best_score) {
best_score = scores[i];
best_score_index = i;
}
}
}
else {
int best_score = 0;
for(int i = 0; i < num_to_compare; i++)
{
if (scores[i] > best_score) {
best_score = scores[i];
best_score_index = i;
}
}
}
return selected_conns[best_score_index];
}
static Connection do_dfp_prog_adaptive_routing(router_state *s, tw_bf *bf, terminal_plus_message *msg, tw_lp *lp, dfp_path_hop_t my_hop_type, int fdest_router_id)
{
int local_router_id = s->router_id;
int my_group_id = s->router_id / s->params->num_routers;
int fdest_group_id = fdest_router_id / s->params->num_routers;
int origin_group_id = msg->origin_router_id / s->params->num_routers;
bool in_intermediate_group = (my_group_id != origin_group_id) && (my_group_id != fdest_group_id);
int adaptive_threshold = s->params->adaptive_threshold;
vector< Connection > poss_min_next_stops;
vector< Connection > poss_intm_next_stops;
Connection nextStopConn;
if (msg->