Commit 3bcbcb62 authored by Nikhil's avatar Nikhil
Browse files

Fix for incorrect busy time in the template code

If this looks correct, the fix will be extended to all models.

Change-Id: I74ecf2f5bd72962f4c3b8f1683b3929f4342dbf5
parent b8df46df
......@@ -726,8 +726,6 @@ static void packet_generate(terminal_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * m
} else {
bf->c11 = 1;
s->issueIdle = 1;
msg->saved_busy_time = s->last_buf_full;
s->last_buf_full = tw_now(lp);
}
if(s->in_send_loop == 0) {
......@@ -777,7 +775,6 @@ static void packet_generate_rc(terminal_state * s, tw_bf * bf, LOCAL_MSG_STRUCT
}
if(bf->c11) {
s->issueIdle = 0;
s->last_buf_full = msg->saved_busy_time;
}
if(bf->c5) {
codes_local_latency_reverse(lp);
......@@ -801,25 +798,43 @@ static void packet_send(terminal_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * msg,
tw_lpid router_id;
std::vector<VC_Entry> entries;
bool noEmptyVC = false;
for(int i = 0; i < s->params->num_vcs; i++) {
if(s->terminal_msgs[0][i] != NULL &&
s->vc_occupancy[0][i] + s->params->chunk_size <= s->params->cn_vc_size) {
if(s->terminal_msgs[0][i] != NULL) {
if(s->vc_occupancy[0][i] + s->params->chunk_size <= s->params->cn_vc_size) {
VC_Entry tmp;
tmp.vc = i; tmp.entry = s->terminal_msgs[0][i];
entries.push_back(tmp);
} else {
noEmptyVC = true;
}
}
}
if(entries.size() == 0) {
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;
}
if(s->last_buf_full > 0.0)
{
bf->c4 = 1;
msg->saved_total_time = s->busy_time;
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);
s->busy_time_sample += (tw_now(lp) - s->last_buf_full);
s->last_buf_full = 0.0;
}
//CHANGE: randomly pick the VC to send on (by default only VC 0 is filed); can be changed.
int pick = tw_rand_integer(lp->rng, 0, entries.size() - 1);
message_list* cur_entry = entries[pick].entry;
......@@ -894,18 +909,6 @@ static void packet_send(terminal_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * msg,
s->issueIdle = 0;
ts += tw_rand_unif(lp->rng);
model_net_method_idle_event(ts, 0, lp);
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;
msg->saved_sample_time = s->busy_time_sample;
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;
}
......@@ -915,10 +918,19 @@ static void packet_send_rc(terminal_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * ms
{
if(bf->c1) {
s->in_send_loop = 1;
if(bf->c3) {
s->last_buf_full = msg->saved_busy_time;
}
return;
}
if(bf->c4)
{
s->busy_time = msg->saved_total_time;
s->last_buf_full = msg->saved_busy_time;
s->busy_time_sample = msg->saved_sample_time;
}
tw_rand_reverse_unif(lp->rng);
tw_rand_reverse_unif(lp->rng);
s->terminal_available_time = msg->saved_available_time;
......@@ -942,12 +954,6 @@ static void packet_send_rc(terminal_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * ms
{
tw_rand_reverse_unif(lp->rng);
s->issueIdle = 1;
if(bf->c6)
{
s->busy_time = msg->saved_total_time;
s->last_buf_full = msg->saved_busy_time;
s->busy_time_sample = msg->saved_sample_time;
}
}
return;
}
......@@ -1466,8 +1472,6 @@ router_packet_receive( router_state * s,
append_to_message_list(s->queued_msgs[next_port],
s->queued_msgs_tail[next_port], next_vc, cur_chunk);
s->queued_count[next_port] += s->params->chunk_size;
msg->saved_busy_time = s->last_buf_full[next_port];
s->last_buf_full[next_port] = tw_now(lp);
}
msg->saved_vc = next_port;
......@@ -1500,7 +1504,6 @@ static void router_packet_receive_rc(router_state * s,
message_list *tail = return_tail(s->queued_msgs[next_port],
s->queued_msgs_tail[next_port], next_vc);
s->queued_count[next_port] -= s->params->chunk_size;
s->last_buf_full[next_port] = msg->saved_busy_time;
delete_message_list(tail);
}
}
......@@ -1529,9 +1532,25 @@ router_packet_send( router_state * s,
if(entries.size() == 0) {
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->c3 = 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;
}
//CHANGE: no priorities among VCs; can be changed.
int pick = tw_rand_integer(lp->rng, 0, entries.size() - 1);
message_list* cur_entry = entries[pick].entry;
......@@ -1642,9 +1661,19 @@ static void router_packet_send_rc(router_state * s,
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->c3)
{
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);
tw_rand_reverse_unif(lp->rng);
......@@ -1677,17 +1706,6 @@ static void router_buf_update(router_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * m
int output_chan = msg->output_chan;
s->vc_occupancy[indx][output_chan] -= s->params->chunk_size;
if(s->last_buf_full[indx])
{
bf->c3 = 1;
msg->saved_rcv_time = s->busy_time[indx];
msg->saved_busy_time = s->last_buf_full[indx];
msg->saved_sample_time = s->busy_time_sample[indx];
s->busy_time[indx] += (tw_now(lp) - s->last_buf_full[indx]);
s->busy_time_sample[indx] += (tw_now(lp) - s->last_buf_full[indx]);
s->last_buf_full[indx] = 0.0;
}
int max_vc_size = s->params->vc_size;
if(indx < s->params->num_cn) {
max_vc_size = s->params->cn_vc_size;
......@@ -1729,12 +1747,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] = msg->saved_busy_time;
}
if(bf->c1) {
message_list* head = return_tail(s->pending_msgs[indx],
s->pending_msgs_tail[indx], output_chan);
......
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