Commit be6f55ae authored by iker_martin's avatar iker_martin
Browse files

Bugfix for reading a configuration file

parent 73d49917
......@@ -17,6 +17,7 @@ ext_functions_t *user_functions;
*/
static int handler(void* user, const char* section, const char* name,
const char* value) {
int ret_value=1;
configuration* pconfig = (configuration*)user;
if(pconfig->actual_resize >= pconfig->n_resizes && pconfig->actual_stage >= pconfig->n_stages) {
......@@ -30,12 +31,13 @@ static int handler(void* user, const char* section, const char* name,
snprintf(stage_name, 10, "stage%zu", pconfig->actual_stage);
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
#define LAST(iter, total) iter < total
if (MATCH("general", "Total_Resizes")) {
pconfig->n_resizes = strtoul(value, NULL, 10) + 1;
user_functions->resizes_f(pconfig);
} else if (MATCH("general", "Total_Stages")) {
pconfig->n_stages = strtoul(value, NULL, 10);
user_functions->stages_f(pconfig);
user_functions->stages_f(pconfig);
} else if (MATCH("general", "Granularity")) {
pconfig->granularity = atoi(value);
} else if (MATCH("general", "SDR")) { // TODO Refactor a nombre manual
......@@ -46,45 +48,45 @@ static int handler(void* user, const char* section, const char* name,
pconfig->rigid_times = atoi(value);
// Iter stage
} else if (MATCH(stage_name, "Stage_Type")) {
} else if (MATCH(stage_name, "Stage_Type") && LAST(pconfig->actual_stage, pconfig->n_stages)) {
//if(pconfig->actual_stage < pconfig->n_stages)
pconfig->stages[pconfig->actual_stage].pt = atoi(value);
} else if (MATCH(stage_name, "Stage_Bytes")) {
} else if (MATCH(stage_name, "Stage_Bytes") && LAST(pconfig->actual_stage, pconfig->n_stages)) {
pconfig->stages[pconfig->actual_stage].bytes = atoi(value);
} else if (MATCH(stage_name, "Stage_Time")) {
} else if (MATCH(stage_name, "Stage_Time") && LAST(pconfig->actual_stage, pconfig->n_stages)) {
pconfig->stages[pconfig->actual_stage].t_stage = (float) atof(value);
pconfig->actual_stage = pconfig->actual_stage+1; // Ultimo elemento del grupo
// Resize stage
} else if (MATCH(resize_name, "Iters")) {
} else if (MATCH(resize_name, "Iters") && LAST(pconfig->actual_resize, pconfig->n_resizes)) {
//if(pconfig->actual_resize < pconfig->n_resizes)
pconfig->groups[pconfig->actual_resize].iters = atoi(value);
} else if (MATCH(resize_name, "Procs")) {
} else if (MATCH(resize_name, "Procs") && LAST(pconfig->actual_resize, pconfig->n_resizes)) {
pconfig->groups[pconfig->actual_resize].procs = atoi(value);
} else if (MATCH(resize_name, "FactorS")) {
} else if (MATCH(resize_name, "FactorS") && LAST(pconfig->actual_resize, pconfig->n_resizes)) {
pconfig->groups[pconfig->actual_resize].factor =(float) atof(value);
} else if (MATCH(resize_name, "Dist")) {
} else if (MATCH(resize_name, "Dist") && LAST(pconfig->actual_resize, pconfig->n_resizes)) {
int aux_value = MALL_DIST_COMPACT;
if (strcmp(value, "spread") == 0) {
aux_value = MALL_DIST_SPREAD;
}
pconfig->groups[pconfig->actual_resize].phy_dist = aux_value;
} else if (MATCH(resize_name, "Asynch_Redistribution_Type")) {
} else if (MATCH(resize_name, "Asynch_Redistribution_Type") && LAST(pconfig->actual_resize, pconfig->n_resizes)) {
pconfig->groups[pconfig->actual_resize].at = atoi(value);
} else if (MATCH(resize_name, "Spawn_Method")) {
} else if (MATCH(resize_name, "Spawn_Method") && LAST(pconfig->actual_resize, pconfig->n_resizes)) {
pconfig->groups[pconfig->actual_resize].sm = atoi(value);
} else if (MATCH(resize_name, "Spawn_Strategy")) {
} else if (MATCH(resize_name, "Spawn_Strategy") && LAST(pconfig->actual_resize, pconfig->n_resizes)) {
pconfig->groups[pconfig->actual_resize].ss = atoi(value);
pconfig->actual_resize = pconfig->actual_resize+1; // Ultimo elemento del grupo
// Unkown case
} else {
return 0; /* unknown section or name, error */
ret_value = 0; /* unknown section or name, error */
}
free(resize_name);
free(stage_name);
return 1;
return ret_value;
}
/*
......
Supports Markdown
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