Commit 9497a9c7 authored by Philip Carns's avatar Philip Carns

add queueing and fix time calculation

parent 35cc7c1f
...@@ -34,6 +34,7 @@ struct client_state ...@@ -34,6 +34,7 @@ struct client_state
int wkld_id; /* identifier returned by workload load fn */ int wkld_id; /* identifier returned by workload load fn */
int target_barrier_count; /* state information for handling barriers */ int target_barrier_count; /* state information for handling barriers */
int current_barrier_count; int current_barrier_count;
tw_stime completion_time;
}; };
struct client_msg struct client_msg
...@@ -178,7 +179,7 @@ static void client_finalize( ...@@ -178,7 +179,7 @@ static void client_finalize(
/* write out some statistics (the current time of each cn as it /* write out some statistics (the current time of each cn as it
* shuts down) * shuts down)
*/ */
sprintf(buffer, "cn_lp:%ld\tfinalize_time:%f\n", (long)lp->gid, tw_now(lp)); sprintf(buffer, "cn_lp:%ld\tcompletion_time:%f\n", (long)lp->gid, ns->completion_time);
ret = lp_io_write(lp->gid, "compute_nodes", strlen(buffer)+1, buffer); ret = lp_io_write(lp->gid, "compute_nodes", strlen(buffer)+1, buffer);
assert(ret == 0); assert(ret == 0);
...@@ -302,6 +303,7 @@ static void handle_client_op_loop_event( ...@@ -302,6 +303,7 @@ static void handle_client_op_loop_event(
switch(m->op_rc.op_type) switch(m->op_rc.op_type)
{ {
case CODES_WK_END: case CODES_WK_END:
ns->completion_time = tw_now(lp);
printf("Client rank %d completed workload.\n", ns->my_rank); printf("Client rank %d completed workload.\n", ns->my_rank);
/* stop issuing events; we are done */ /* stop issuing events; we are done */
return; return;
......
...@@ -26,6 +26,7 @@ enum svr_event_type ...@@ -26,6 +26,7 @@ enum svr_event_type
struct svr_state struct svr_state
{ {
tw_stime next_idle;
}; };
struct svr_msg struct svr_msg
...@@ -33,6 +34,7 @@ struct svr_msg ...@@ -33,6 +34,7 @@ struct svr_msg
enum svr_event_type event_type; enum svr_event_type event_type;
struct codes_workload_op op; struct codes_workload_op op;
tw_lpid src; /* source of this request or ack */ tw_lpid src; /* source of this request or ack */
tw_stime next_idle_rc;
}; };
static void svr_init( static void svr_init(
...@@ -81,6 +83,8 @@ static void svr_init( ...@@ -81,6 +83,8 @@ static void svr_init(
{ {
memset(ns, 0, sizeof(*ns)); memset(ns, 0, sizeof(*ns));
ns->next_idle = tw_now(lp);
return; return;
} }
...@@ -131,7 +135,7 @@ static void svr_finalize( ...@@ -131,7 +135,7 @@ static void svr_finalize(
/* write out some statistics (the current time of each server as it /* write out some statistics (the current time of each server as it
* shuts down) * shuts down)
*/ */
sprintf(buffer, "svr_lp:%ld\tfinalize_time:%f\n", (long)lp->gid, tw_now(lp)); sprintf(buffer, "svr_lp:%ld\tcompletion_time:%f\n", (long)lp->gid, ns->next_idle);
ret = lp_io_write(lp->gid, "servers", strlen(buffer)+1, buffer); ret = lp_io_write(lp->gid, "servers", strlen(buffer)+1, buffer);
assert(ret == 0); assert(ret == 0);
...@@ -169,13 +173,22 @@ static void handle_svr_op_event( ...@@ -169,13 +173,22 @@ static void handle_svr_op_event(
svr_msg * m, svr_msg * m,
tw_lp * lp) tw_lp * lp)
{ {
printf("handle_svr_op_event at lp %ld, type %d\n", lp->gid, m->op.op_type);
m->next_idle_rc = ns->next_idle;
/* NOTE: this isn't a real server simulator, but we do want time to /* NOTE: this isn't a real server simulator, but we do want time to
* elapse so that we can do correctness/regression testing. We pick the * elapse so that we can do correctness/regression testing. For testing
* service time by using the op type as the elapsed time. * purposes we use the value of the op_type field as the amount of
* elapsed time for the operation to consume.
*/ */
if(ns->next_idle > tw_now(lp))
ns->next_idle += m->op.op_type;
else
ns->next_idle = tw_now(lp) + m->op.op_type;
/* send event back to cn to let it know the operation is done */ /* send event back to cn to let it know the operation is done */
cn_op_complete(lp, m->op.op_type, m->src); cn_op_complete(lp, ns->next_idle-tw_now(lp), m->src);
return; return;
} }
...@@ -186,6 +199,7 @@ static void handle_svr_op_event_rc( ...@@ -186,6 +199,7 @@ static void handle_svr_op_event_rc(
svr_msg * m, svr_msg * m,
tw_lp * lp) tw_lp * lp)
{ {
ns->next_idle = m->next_idle_rc;
cn_op_complete_rc(lp); cn_op_complete_rc(lp);
return; return;
} }
......
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