From 288247da1000f7fd48b9533ad71a67ad528eed25 Mon Sep 17 00:00:00 2001 From: mubarak Date: Thu, 4 Jun 2015 16:55:18 -0500 Subject: [PATCH] Adding further updates to the dragonfly routing (statistics for adaptive routing updated, conditions for queue congestion sensing updated) --- src/models/networks/model-net/dragonfly.c | 36 ++++++++++++++++------ tests/conf/modelnet-test-dragonfly.conf | 10 +++--- tests/modelnet-test-dragonfly.c | 37 +++++++++++++++++++++-- 3 files changed, 67 insertions(+), 16 deletions(-) diff --git a/src/models/networks/model-net/dragonfly.c b/src/models/networks/model-net/dragonfly.c index 8c567d9..78acf61 100644 --- a/src/models/networks/model-net/dragonfly.c +++ b/src/models/networks/model-net/dragonfly.c @@ -539,7 +539,7 @@ void router_credit_send(router_state * s, tw_bf * bf, terminal_message * msg, tw } //if(dest == TRACK) // printf("\n LP %d sending credit back to dest %d at channel %d last hop %d ", lp->gid, dest, msg->saved_vc, msg->last_hop); - buf_msg->origin_router_id = lp->gid; + buf_msg->origin_router_id = s->router_id; buf_msg->vc_index = msg->saved_vc; buf_msg->type=type; buf_msg->last_hop = msg->last_hop; @@ -671,7 +671,7 @@ void packet_send(terminal_state * s, tw_bf * bf, terminal_message * msg, tw_lp * memcpy(m+1, model_net_method_get_edata(DRAGONFLY, msg), msg->remote_event_size_bytes); } - m->origin_router_id = router_id; + m->origin_router_id = s->router_id; m->type = R_ARRIVE; m->src_terminal_id = lp->gid; m->saved_vc = vc; @@ -727,7 +727,9 @@ void packet_arrive(terminal_state * s, tw_bf * bf, terminal_message * msg, tw_lp if(msg->path_type == NON_MINIMAL) nonmin_count++; - + + if(msg->path_type != MINIMAL && msg->path_type != NON_MINIMAL) + printf("\n Wrong message path type %d ", msg->path_type); #if DEBUG == 1 if( msg->packet_ID == TRACK && msg->chunk_id == num_chunks-1) { @@ -1366,8 +1368,8 @@ static int do_adaptive_routing( router_state * s, nonmin_out_port = get_output_port(s, bf, msg, lp, nonmin_next_stop); int nonmin_port_count = s->vc_occupancy[nonmin_out_port]; int min_port_count = s->vc_occupancy[minimal_out_port]; - int nonmin_vc = s->vc_occupancy[nonmin_out_port * s->params->num_vcs + 2]; - int min_vc = s->vc_occupancy[minimal_out_port * s->params->num_vcs + 1]; + //int nonmin_vc = s->vc_occupancy[nonmin_out_port * s->params->num_vcs + 2]; + //int min_vc = s->vc_occupancy[minimal_out_port * s->params->num_vcs + 1]; // Now get the expected number of hops to be traversed for both routes int dest_group_id = dest_router_id / s->params->num_routers; @@ -1384,7 +1386,17 @@ static int do_adaptive_routing( router_state * s, // modified according to booksim adaptive routing condition /* if((min_vc <= (nonmin_vc * 2 + adaptive_threshold) && minimal_out_port == nonmin_out_port) || (min_port_count <= (nonmin_port_count * 2 + adaptive_threshold) && minimal_out_port != nonmin_out_port))*/ - if(num_min_hops * min_port_count <= num_nonmin_hops * nonmin_port_count) + + /* average the local queues of the router */ + unsigned int q_avg = 0; + int i; + for( i = 0; i < s->params->radix; i++) + { + if( i != minimal_out_port) + q_avg += s->vc_occupancy[i]; + } + q_avg = q_avg / (s->params->radix - 1); + if(num_min_hops * min_port_count <= (num_nonmin_hops * (q_avg + 1))) { msg->path_type = MINIMAL; next_stop = minimal_next_stop; @@ -1443,15 +1455,21 @@ router_packet_send( router_state * s, intm_id = (local_grp_id + 2) % s->params->num_groups; /* progressive adaptive routing makes a check at every node/router at the source group to sense congestion. Once it does and decides on taking non-minimal path, it does not check any longer. */ +// printf("\n local grp id %d origin router id %d ", local_grp_id, msg->origin_router_id / s->params->num_routers); if(routing == PROG_ADAPTIVE && msg->path_type != NON_MINIMAL && local_grp_id == ( msg->origin_router_id / s->params->num_routers)) - next_stop = do_adaptive_routing(s, bf, msg, lp, dest_router_id, intm_id); + { + next_stop = do_adaptive_routing(s, bf, msg, lp, dest_router_id, intm_id); + } else if(msg->last_hop == TERMINAL && routing == ADAPTIVE) - next_stop = do_adaptive_routing(s, bf, msg, lp, dest_router_id, intm_id); + { + next_stop = do_adaptive_routing(s, bf, msg, lp, dest_router_id, intm_id); + } else { - msg->path_type = routing; /*defaults to the routing algorithm if we don't have adaptive routing here*/ + if(routing == MINIMAL || routing == NON_MINIMAL) + msg->path_type = routing; /*defaults to the routing algorithm if we don't have adaptive routing here*/ next_stop = get_next_stop(s, bf, msg, lp, msg->path_type, dest_router_id, intm_id); } output_port = get_output_port(s, bf, msg, lp, next_stop); diff --git a/tests/conf/modelnet-test-dragonfly.conf b/tests/conf/modelnet-test-dragonfly.conf index ba8b11c..af656d8 100644 --- a/tests/conf/modelnet-test-dragonfly.conf +++ b/tests/conf/modelnet-test-dragonfly.conf @@ -2,9 +2,9 @@ LPGROUPS { MODELNET_GRP { - repetitions="264"; - server="4"; - modelnet_dragonfly="4"; + repetitions="36"; + server="2"; + modelnet_dragonfly="2"; dragonfly_router="1"; } } @@ -17,10 +17,10 @@ PARAMS chunk_size="32"; # modelnet_scheduler="round-robin"; num_vcs="1"; - num_routers="8"; + num_routers="4"; local_vc_size="262144"; global_vc_size="262144"; - cn_vc_size="65536"; + cn_vc_size="262144"; local_bandwidth="5.25"; global_bandwidth="4.7"; cn_bandwidth="5.25"; diff --git a/tests/modelnet-test-dragonfly.c b/tests/modelnet-test-dragonfly.c index e177b21..e5d42bf 100644 --- a/tests/modelnet-test-dragonfly.c +++ b/tests/modelnet-test-dragonfly.c @@ -24,13 +24,15 @@ #include "codes/configuration.h" #include "codes/lp-type-lookup.h" -#define NUM_REQS 20 /* number of requests sent by each server */ +#define NUM_REQS 5 /* number of requests sent by each server */ #define PAYLOAD_SZ 2048 /* size of simulated data payload, bytes */ +#define TRAFFIC 0 static int net_id = 0; static int num_routers = 0; static int num_servers = 0; static int offset = 2; +static int num_reps = 0; /* whether to pull instead of push */ static int do_pull = 0; @@ -42,6 +44,11 @@ static int lps_per_rep = 0; typedef struct svr_msg svr_msg; typedef struct svr_state svr_state; +/* global variables for codes mapping */ +static char group_name[MAX_NAME_LENGTH]; +static char lp_type_name[MAX_NAME_LENGTH]; +static int group_index, lp_type_index, rep_id, offset; + /* types of events that will constitute triton requests */ enum svr_event { @@ -51,6 +58,11 @@ enum svr_event LOCAL /* local event */ }; +enum traffic_pattern +{ + UNIFORM_RANDOM, /* uniform random traffic */ + WORST_CASE /* sends packets to neighboring groups */ +}; struct svr_state { int msg_sent_count; /* requests sent */ @@ -326,6 +338,7 @@ static void handle_kickoff_event( svr_msg * m, tw_lp * lp) { + char anno[MAX_NAME_LENGTH]; svr_msg * m_local = malloc(sizeof(svr_msg)); svr_msg * m_remote = malloc(sizeof(svr_msg)); @@ -344,12 +357,22 @@ static void handle_kickoff_event( num_routers_per_rep = codes_mapping_get_lp_count("MODELNET_GRP", 1, "dragonfly_router", NULL, 1); + num_reps = codes_mapping_get_group_reps("MODELNET_GRP"); + lps_per_rep = num_servers_per_rep * 2 + num_routers_per_rep; + + codes_mapping_get_lp_info(lp->gid, group_name, &group_index, lp_type_name, &lp_type_index, anno, &rep_id, &offset); int opt_offset = 0; int total_lps = num_servers * 2 + num_routers; - int dest_svr = tw_rand_integer(lp->rng, 0, num_servers - 1); + int dest_svr; + if(TRAFFIC == UNIFORM_RANDOM) + dest_svr = tw_rand_integer(lp->rng, 0, num_servers - 1); + else + { + dest_svr = ((rep_id * num_servers_per_rep) + (num_servers_per_rep * 2)) % (num_reps * num_servers_per_rep); + } dest_svr = dest_svr + ((dest_svr / num_servers_per_rep) * (num_routers_per_rep + num_servers_per_rep)); if (do_pull){ @@ -440,6 +463,7 @@ static void handle_ack_event( svr_msg * m, tw_lp * lp) { + char anno[MAX_NAME_LENGTH]; svr_msg * m_local = malloc(sizeof(svr_msg)); svr_msg * m_remote = malloc(sizeof(svr_msg)); @@ -448,6 +472,8 @@ static void handle_ack_event( memcpy(m_remote, m_local, sizeof(svr_msg)); m_remote->svr_event_type = (do_pull) ? ACK : REQ; + + codes_mapping_get_lp_info(lp->gid, group_name, &group_index, lp_type_name, &lp_type_index, anno, &rep_id, &offset); // printf("handle_ack_event(), lp %llu.\n", (unsigned long long)lp->gid); @@ -455,6 +481,13 @@ static void handle_ack_event( // printf("\n m->src %d lp->gid %d ", m->src, lp->gid); int dest_svr = tw_rand_integer(lp->rng, 0, num_servers - 1); + if(TRAFFIC == UNIFORM_RANDOM) + dest_svr = tw_rand_integer(lp->rng, 0, num_servers - 1); + else + { + dest_svr = ((rep_id * num_servers_per_rep) + (num_servers_per_rep * 2)) % (num_reps * num_servers_per_rep); + } + dest_svr = dest_svr + ((dest_svr / num_servers_per_rep) * (num_routers_per_rep + num_servers_per_rep)); if(ns->msg_sent_count < NUM_REQS) -- 2.26.2