Commit f947e07d authored by Philip Carns's avatar Philip Carns

draft of workload gen reverse computation

parent 70488a96
......@@ -17,20 +17,64 @@ extern struct codes_workload_method test_workload_method;
static struct codes_workload_method *method_array[] =
{&test_workload_method, NULL};
/* NOTE: we could make this faster with a smarter data structure. For now
* we just have a linked list of rank_queue structs, one per rank that has
* opened the workload. We then have a linked list off of each of those
* to hold a lifo queue of operations that have been reversed for that rank.
*/
/* holds an operation that has been reversed */
struct rc_op
{
struct codes_workload_op op;
struct rc_op* next;
};
/* tracks lifo queue of reversed operations for a given rank */
struct rank_queue
{
int rank;
struct rc_op *lifo;
struct rank_queue *next;
};
static struct rank_queue *ranks = NULL;
int codes_workload_load(const char* type, const char* params, int rank)
{
int i;
int ret;
struct rank_queue *tmp;
for(i=0; method_array[i] != NULL; i++)
{
if(strcmp(method_array[i]->method_name, type) == 0)
{
/* load appropriate workload generator */
ret = method_array[i]->codes_workload_load(params, rank);
if(ret < 0)
{
return(-1);
}
/* are we tracking information for this rank yet? */
tmp = ranks;
while(tmp)
{
if(tmp->rank == rank)
break;
tmp = tmp->next;
}
if(tmp == NULL)
{
tmp = malloc(sizeof(*tmp));
assert(tmp);
tmp->rank = rank;
tmp->lifo = NULL;
tmp->next = ranks;
ranks = tmp;
}
return(i);
}
}
......@@ -41,6 +85,33 @@ int codes_workload_load(const char* type, const char* params, int rank)
void codes_workload_get_next(int wkld_id, int rank, struct codes_workload_op *op)
{
struct rank_queue *tmp;
struct rc_op *tmp_op;
/* first look to see if we have a reversed operation that we can
* re-issue
*/
tmp = ranks;
while(tmp)
{
if(tmp->rank == rank)
break;
tmp = tmp->next;
}
assert(tmp);
if(tmp->lifo)
{
tmp_op = tmp->lifo;
tmp->lifo = tmp_op->next;
*op = tmp_op->op;
free(tmp_op);
printf("codes_workload_get_next re-issuing reversed operation.\n");
return;
}
/* ask generator for the next operation */
printf("codes_workload_get_next issuing new operation.\n");
method_array[wkld_id]->codes_workload_get_next(rank, op);
return;
......@@ -48,9 +119,24 @@ void codes_workload_get_next(int wkld_id, int rank, struct codes_workload_op *op
void codes_workload_get_next_rc(int wkld_id, int rank, const struct codes_workload_op *op)
{
/* TODO: fill this in */
struct rank_queue *tmp;
struct rc_op *tmp_op;
tmp = ranks;
while(tmp)
{
if(tmp->rank == rank)
break;
tmp = tmp->next;
}
assert(tmp);
tmp_op = malloc(sizeof(*tmp_op));
assert(tmp_op);
tmp_op->op = *op;
tmp_op->next = tmp->lifo;
tmp->lifo = tmp_op;
assert(0);
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