Commit 84879755 authored by Jonathan Jenkins's avatar Jonathan Jenkins

anno. lookup in codes-mapping and support in the LSM

parent 06623964
......@@ -40,6 +40,13 @@ int codes_mapping_get_lp_global_rel_id(tw_lpid gid);
* (for multiple LPs in a repetition). */
void codes_mapping_get_lp_info(tw_lpid gid, char* grp_name, int* grp_id, int* lp_type_id, char* lp_type_name, int* grp_rep_id, int* offset);
/* given the group and LP type name, return the annotation (or NULL if there is
* none) */
const char* codes_mapping_get_annotation_by_name(char *grp_name, char *lp_type_name);
/* given the LP ID, return the annotation (or NULL if there is none)
* NOTE: both functions have equivalent results. The different ways of accessing
* are for convenience */
const char* codes_mapping_get_annotation_by_lpid(tw_lpid gid);
/*
* Local variables:
......
......@@ -243,8 +243,8 @@ int main(
/* for this example, we read from a separate configuration group for
* server message parameters. Since they are constant for all LPs,
* go ahead and read them prior to running */
configuration_get_value_int(&config, param_group_nm, num_reqs_key, &num_reqs);
configuration_get_value_int(&config, param_group_nm, payload_sz_key, &payload_sz);
configuration_get_value_int(&config, param_group_nm, num_reqs_key, NULL, &num_reqs);
configuration_get_value_int(&config, param_group_nm, payload_sz_key, NULL, &payload_sz);
/* begin simulation */
tw_run();
......
......@@ -317,6 +317,98 @@ void codes_mapping_setup()
tw_define_lps(codes_mapping_get_lps_for_pe(), message_size, 0);
}
/* given the group and LP type name, return the annotation (or NULL) */
const char* codes_mapping_get_annotation_by_name(char *grp_name, char *lp_type_name){
int grp, lpt, lp_types_count;
short found = 0;
// find the group
for(grp = 0; grp < lpconf.lpgroups_count; grp++) {
if(strcmp(lpconf.lpgroups[grp].name, grp_name) == 0) {
found = 1;
break;
}
}
assert(found);
found = 0;
lp_types_count = lpconf.lpgroups[grp].lptypes_count;
// find the lp type
for(lpt = 0; lpt < lp_types_count; lpt++) {
if(strcmp(lpconf.lpgroups[grp].lptypes[lpt].name, lp_type_name) == 0) {
found = 1;
break;
}
}
assert(found);
const char * anno = lpconf.lpgroups[grp].lptypes[lpt].anno;
if (anno[0]=='\0'){
return NULL;
}
else{
return anno;
}
}
const char* codes_mapping_get_annotation_by_lpid(tw_lpid gid){
int grp, lpt, rep, grp_offset, lp_offset, rep_offset;
int lp_tmp_id, lp_types_count, lp_count;
unsigned long grp_lp_count=0;
short found = 0;
/* Find the group id first */
for(grp = 0; grp < lpconf.lpgroups_count; grp++)
{
grp_offset = 0;
rep_offset = 0;
rep = lpconf.lpgroups[grp].repetitions;
lp_types_count = lpconf.lpgroups[grp].lptypes_count;
for(lpt = 0; lpt < lp_types_count; lpt++)
{
lp_count = lpconf.lpgroups[grp].lptypes[lpt].count;
grp_offset += (rep * lp_count);
rep_offset += lp_count;
}
/* Each gid is assigned an increasing number starting from 0th group and 0th lp type
* so we check here if the gid lies within the numeric range of a group */
if(gid >= grp_lp_count && gid < grp_lp_count + grp_offset)
{
strcpy(local_grp_name, lpconf.lpgroups[grp].name);
lp_offset = gid - grp_lp_count; /* gets the lp offset starting from the point where the group begins */
int grp_rep_id = lp_offset / rep_offset;
lp_tmp_id = lp_offset - (grp_rep_id * rep_offset);
found = 1;
break;
}
grp_lp_count += grp_offset; /* keep on increasing the group lp count to next group range*/
}
assert(found);
lp_offset = 0;
found = 0; /* reset found for finding LP type */
/* Now we compute the LP type ID here based on the lp offset that we just got */
for(lpt = 0; lpt < lp_types_count; lpt++)
{
lp_count = lpconf.lpgroups[grp].lptypes[lpt].count;
if(lp_tmp_id >= lp_offset && lp_tmp_id < lp_offset + lp_count)
{
found = 1;
if (lpconf.lpgroups[grp].lptypes[lpt].anno[0] == '\0'){
return NULL;
}
else{
return lpconf.lpgroups[grp].lptypes[lpt].anno;
}
}
lp_offset += lp_count;
}
assert(found);
return NULL;
}
/*
* Local variables:
......
......@@ -164,7 +164,7 @@ tw_lptype lsm_lp =
* lsm_load_config
* - load configuration disk parameters
*/
static void lsm_load_config (ConfigHandle *ch, char *name, lsm_state_t *ns)
static void lsm_load_config (ConfigHandle *ch, char *name, lsm_state_t *ns, tw_lp *lp)
{
disk_model_t *model;
char **values;
......@@ -175,8 +175,11 @@ static void lsm_load_config (ConfigHandle *ch, char *name, lsm_state_t *ns)
model = (disk_model_t *) malloc(sizeof(disk_model_t));
assert(model);
// get my annotation (if any)
const char *anno = codes_mapping_get_annotation_by_lpid(lp->gid);
// request sizes
rc = configuration_get_multivalue(ch, name, "request_sizes", NULL,
rc = configuration_get_multivalue(ch, name, "request_sizes", anno,
&values,&length);
assert(rc == 1);
model->request_sizes = malloc(sizeof(int)*length);
......@@ -189,7 +192,7 @@ static void lsm_load_config (ConfigHandle *ch, char *name, lsm_state_t *ns)
free(values);
// write rates
rc = configuration_get_multivalue(ch, name, "write_rates", NULL,
rc = configuration_get_multivalue(ch, name, "write_rates", anno,
&values,&length);
assert(rc == 1);
model->write_rates = malloc(sizeof(double)*length);
......@@ -202,7 +205,7 @@ static void lsm_load_config (ConfigHandle *ch, char *name, lsm_state_t *ns)
free(values);
// read rates
rc = configuration_get_multivalue(ch, name, "read_rates", NULL,
rc = configuration_get_multivalue(ch, name, "read_rates", anno,
&values,&length);
assert(rc == 1);
model->read_rates = malloc(sizeof(double)*length);
......@@ -215,7 +218,7 @@ static void lsm_load_config (ConfigHandle *ch, char *name, lsm_state_t *ns)
free(values);
// write overheads
rc = configuration_get_multivalue(ch, name, "write_overheads", NULL,
rc = configuration_get_multivalue(ch, name, "write_overheads", anno,
&values,&length);
assert(rc == 1);
model->write_overheads = malloc(sizeof(double)*length);
......@@ -228,7 +231,7 @@ static void lsm_load_config (ConfigHandle *ch, char *name, lsm_state_t *ns)
free(values);
// read overheades
rc = configuration_get_multivalue(ch, name, "read_overheads", NULL,
rc = configuration_get_multivalue(ch, name, "read_overheads", anno,
&values,&length);
assert(rc == 1);
model->read_overheads = malloc(sizeof(double)*length);
......@@ -241,7 +244,7 @@ static void lsm_load_config (ConfigHandle *ch, char *name, lsm_state_t *ns)
free(values);
// write seek latency
rc = configuration_get_multivalue(ch, name, "write_seeks", NULL,
rc = configuration_get_multivalue(ch, name, "write_seeks", anno,
&values,&length);
assert(rc == 1);
model->write_seeks = malloc(sizeof(double)*length);
......@@ -254,7 +257,7 @@ static void lsm_load_config (ConfigHandle *ch, char *name, lsm_state_t *ns)
free(values);
// read seek latency
rc = configuration_get_multivalue(ch, name, "read_seeks", NULL,
rc = configuration_get_multivalue(ch, name, "read_seeks", anno,
&values,&length);
assert(rc == 1);
model->read_seeks = malloc(sizeof(double)*length);
......@@ -509,7 +512,7 @@ static void lsm_event (lsm_state_t *ns, tw_bf *b, lsm_message_t *m, tw_lp *lp)
printf("svr(%llu): INIT name:%s\n",
(unsigned long long)lp->gid,
m->u.init.name);
lsm_load_config(&config, m->u.init.name, ns);
lsm_load_config(&config, m->u.init.name, ns, lp);
break;
case LSM_WRITE_REQUEST:
case LSM_READ_REQUEST:
......
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