Commit 2cf11582 authored by Neil McGlohon's avatar Neil McGlohon
Browse files

Dragonfly Plus: get connections by type optimization

parent 781cfeb9
...@@ -24,8 +24,8 @@ using namespace std; ...@@ -24,8 +24,8 @@ using namespace std;
enum ConnectionType enum ConnectionType
{ {
CONN_LOCAL = 1, CONN_LOCAL = 1,
CONN_GLOBAL, CONN_GLOBAL = 2,
CONN_TERMINAL CONN_TERMINAL = 3
}; };
/** /**
...@@ -79,6 +79,7 @@ class ConnectionManager { ...@@ -79,6 +79,7 @@ class ConnectionManager {
set< int > _other_groups_i_connect_to_set; set< int > _other_groups_i_connect_to_set;
map< int, vector< Connection > > _connections_to_groups_map; //maps group ID to connections to said group map< int, vector< Connection > > _connections_to_groups_map; //maps group ID to connections to said group
map< int, vector< Connection > > _all_conns_by_type_map;
// map< int, vector< Connection > > intermediateRouterToGroupMap; //maps group id to list of routers that connect to it. // map< int, vector< Connection > > intermediateRouterToGroupMap; //maps group id to list of routers that connect to it.
// //ex: intermediateRouterToGroupMap[3] returns a vector // //ex: intermediateRouterToGroupMap[3] returns a vector
...@@ -423,28 +424,20 @@ vector< Connection > ConnectionManager::get_connections_to_group(int dest_group_ ...@@ -423,28 +424,20 @@ vector< Connection > ConnectionManager::get_connections_to_group(int dest_group_
vector< Connection > ConnectionManager::get_connections_by_type(ConnectionType type) vector< Connection > ConnectionManager::get_connections_by_type(ConnectionType type)
{ {
map< int, vector< Connection > > theMap;
switch (type) switch (type)
{ {
case CONN_LOCAL: case CONN_LOCAL:
theMap = intraGroupConnections; return _all_conns_by_type_map[CONN_LOCAL];
break; break;
case CONN_GLOBAL: case CONN_GLOBAL:
theMap = globalConnections; return _all_conns_by_type_map[CONN_GLOBAL];
break; break;
case CONN_TERMINAL: case CONN_TERMINAL:
theMap = terminalConnections; return _all_conns_by_type_map[CONN_TERMINAL];
break; break;
} default:
tw_error(TW_LOC, "Bad enum type\n");
vector< Connection > retVec; }
map< int, vector< Connection > >::iterator it;
for(it = theMap.begin(); it != theMap.end(); it++)
{
retVec.insert(retVec.end(), (*it).second.begin(), (*it).second.end());
}
return retVec;
} }
vector< int > ConnectionManager::get_connected_group_ids() vector< int > ConnectionManager::get_connected_group_ids()
...@@ -454,14 +447,14 @@ vector< int > ConnectionManager::get_connected_group_ids() ...@@ -454,14 +447,14 @@ vector< int > ConnectionManager::get_connected_group_ids()
void ConnectionManager::solidify_connections() void ConnectionManager::solidify_connections()
{ {
//-- other groups connect to
set< int >::iterator it; set< int >::iterator it;
for(it = _other_groups_i_connect_to_set.begin(); it != _other_groups_i_connect_to_set.end(); it++) for(it = _other_groups_i_connect_to_set.begin(); it != _other_groups_i_connect_to_set.end(); it++)
{ {
_other_groups_i_connect_to.push_back(*it); _other_groups_i_connect_to.push_back(*it);
} }
//--connections to group
for(it = _other_groups_i_connect_to_set.begin(); it != _other_groups_i_connect_to_set.end(); it++) for(it = _other_groups_i_connect_to_set.begin(); it != _other_groups_i_connect_to_set.end(); it++)
{ {
int dest_group_id = *it; int dest_group_id = *it;
...@@ -481,6 +474,35 @@ void ConnectionManager::solidify_connections() ...@@ -481,6 +474,35 @@ void ConnectionManager::solidify_connections()
_connections_to_groups_map[dest_group_id] = conns_to_group; _connections_to_groups_map[dest_group_id] = conns_to_group;
} }
//--get connections by type
map< int, vector< Connection > > theMap;
for ( int enum_int = CONN_LOCAL; enum_int != CONN_TERMINAL + 1; enum_int++ )
{
switch (enum_int)
{
case CONN_LOCAL:
theMap = intraGroupConnections;
break;
case CONN_GLOBAL:
theMap = globalConnections;
break;
case CONN_TERMINAL:
theMap = terminalConnections;
break;
default:
tw_error(TW_LOC, "Bad enum type\n");
}
vector< Connection > retVec;
map< int, vector< Connection > >::iterator it;
for(it = theMap.begin(); it != theMap.end(); it++)
{
retVec.insert(retVec.end(), (*it).second.begin(), (*it).second.end());
}
_all_conns_by_type_map[enum_int] = retVec;
}
} }
......
...@@ -1270,8 +1270,7 @@ void router_plus_setup(router_state *r, tw_lp *lp) ...@@ -1270,8 +1270,7 @@ void router_plus_setup(router_state *r, tw_lp *lp)
} }
} }
if (r->dfp_router_type == SPINE) r->connMan->solidify_connections();
r->connMan->solidify_connections();
return; return;
} }
...@@ -2947,7 +2946,7 @@ static Connection do_dfp_routing(router_state *s, ...@@ -2947,7 +2946,7 @@ static Connection do_dfp_routing(router_state *s,
else if (my_group_id == fdest_group_id) { //then we just route minimally else if (my_group_id == fdest_group_id) { //then we just route minimally
vector< Connection > poss_next_stops = get_legal_minimal_stops(s, bf, msg, lp, fdest_router_id); vector< Connection > poss_next_stops = get_legal_minimal_stops(s, bf, msg, lp, fdest_router_id);
if (poss_next_stops.size() < 1) if (poss_next_stops.size() < 1)
tw_error(TW_LOC, "DEAD END WHEN ROUTING LOCALLY\n"); tw_error(TW_LOC, "DEAD END WHEN ROUTING LOCALLY - My Router ID: %d FDest Router ID: %d\n", my_router_id, fdest_router_id);
Connection best_min_conn = get_absolute_best_connection_from_conns(s, bf, msg, lp, poss_next_stops); Connection best_min_conn = get_absolute_best_connection_from_conns(s, bf, msg, lp, poss_next_stops);
return best_min_conn; return best_min_conn;
......
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