Commit b8429aff authored by iker_martin's avatar iker_martin
Browse files

Valgrind checked. Functional code

parent 05131486
...@@ -19,6 +19,10 @@ static int handler(void* user, const char* section, const char* name, ...@@ -19,6 +19,10 @@ static int handler(void* user, const char* section, const char* name,
const char* value) { const char* value) {
configuration* pconfig = (configuration*)user; configuration* pconfig = (configuration*)user;
if(pconfig->actual_resize >= pconfig->n_resizes && pconfig->actual_stage >= pconfig->n_stages) {
return 1; // There is no more work to perform
}
char *resize_name = malloc(10 * sizeof(char)); char *resize_name = malloc(10 * sizeof(char));
snprintf(resize_name, 10, "resize%d", pconfig->actual_resize); snprintf(resize_name, 10, "resize%d", pconfig->actual_resize);
...@@ -96,6 +100,8 @@ configuration *read_ini_file(char *file_name, ext_functions_t init_functions) { ...@@ -96,6 +100,8 @@ configuration *read_ini_file(char *file_name, ext_functions_t init_functions) {
printf("Error when reserving configuration structure\n"); printf("Error when reserving configuration structure\n");
return NULL; return NULL;
} }
config->n_resizes = 1;
config->n_stages = 1;
config->actual_resize=0; config->actual_resize=0;
config->actual_stage=0; config->actual_stage=0;
......
...@@ -243,11 +243,7 @@ void print_global_results(results_data results, size_t resizes) { ...@@ -243,11 +243,7 @@ void print_global_results(results_data results, size_t resizes) {
void init_results_data(results_data *results, size_t resizes, size_t stages, size_t iters_size) { void init_results_data(results_data *results, size_t resizes, size_t stages, size_t iters_size) {
size_t i; size_t i;
printf("Test 1 R=%ld\n", resizes); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
double *test = calloc(1, sizeof(double));
printf("Test 2 R=%ld\n", resizes); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
results->spawn_time = calloc(resizes, sizeof(double)); results->spawn_time = calloc(resizes, sizeof(double));
printf("Test 3\n"); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
results->spawn_real_time = calloc(resizes, sizeof(double)); results->spawn_real_time = calloc(resizes, sizeof(double));
results->sync_time = calloc(resizes, sizeof(double)); results->sync_time = calloc(resizes, sizeof(double));
results->async_time = calloc(resizes, sizeof(double)); results->async_time = calloc(resizes, sizeof(double));
...@@ -255,13 +251,10 @@ void init_results_data(results_data *results, size_t resizes, size_t stages, siz ...@@ -255,13 +251,10 @@ void init_results_data(results_data *results, size_t resizes, size_t stages, siz
results->iters_size = iters_size + RESULTS_EXTRA_SIZE; results->iters_size = iters_size + RESULTS_EXTRA_SIZE;
results->iters_time = calloc(results->iters_size, sizeof(double)); results->iters_time = calloc(results->iters_size, sizeof(double));
printf("Test 6\n"); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
results->stage_times = malloc(stages * sizeof(double*)); results->stage_times = malloc(stages * sizeof(double*));
printf("Test 7\n"); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
for(i=0; i<stages; i++) { for(i=0; i<stages; i++) {
results->stage_times[i] = calloc(results->iters_size, sizeof(double)); results->stage_times[i] = calloc(results->iters_size, sizeof(double));
} }
printf("Test 8\n"); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
results->iters_async = 0; results->iters_async = 0;
results->iter_index = 0; results->iter_index = 0;
......
...@@ -379,9 +379,7 @@ void init_application() { ...@@ -379,9 +379,7 @@ void init_application() {
//config_file = read_ini_file(group->argv[1]); //config_file = read_ini_file(group->argv[1]);
init_config(group->argv[1], &config_file); init_config(group->argv[1], &config_file);
results = malloc(sizeof(results_data)); results = malloc(sizeof(results_data));
printf("Test 0 P%d -- Resizes=%d Stages=%d Iters=%d\n", group->myId, config_file->n_resizes, config_file->n_stages, config_file->groups[group->grp].iters); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
init_results_data(results, (size_t)config_file->n_resizes, (size_t)config_file->n_stages, (size_t)config_file->groups[group->grp].iters); init_results_data(results, (size_t)config_file->n_resizes, (size_t)config_file->n_stages, (size_t)config_file->groups[group->grp].iters);
printf("Test F P%d\n", group->myId); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
if(config_file->sdr) { if(config_file->sdr) {
malloc_comm_array(&(group->sync_array), config_file->sdr , group->myId, group->numP); malloc_comm_array(&(group->sync_array), config_file->sdr , group->myId, group->numP);
} }
...@@ -393,7 +391,9 @@ void init_application() { ...@@ -393,7 +391,9 @@ void init_application() {
config_file->latency_m = latency(group->myId, group->numP, comm); config_file->latency_m = latency(group->myId, group->numP, comm);
config_file->bw_m = bandwidth(group->myId, group->numP, comm, config_file->latency_m, message_tam); config_file->bw_m = bandwidth(group->myId, group->numP, comm, config_file->latency_m, message_tam);
printf("Test 0\n");
obtain_op_times(1); obtain_op_times(1);
printf("Test 1\n");
} }
/* /*
...@@ -411,6 +411,7 @@ void obtain_op_times(int compute) { ...@@ -411,6 +411,7 @@ void obtain_op_times(int compute) {
int i; int i;
double time = 0; double time = 0;
for(i=0; i<config_file->n_stages; i++) { for(i=0; i<config_file->n_stages; i++) {
printf("Test P%d 0.5\n", group->myId);
time+=init_stage(config_file, i, *group, comm, compute); time+=init_stage(config_file, i, *group, comm, compute);
} }
if(!compute) {results->wasted_time += time;} if(!compute) {results->wasted_time += time;}
......
...@@ -88,6 +88,7 @@ void malloc_config_stages(configuration *user_config) { ...@@ -88,6 +88,7 @@ void malloc_config_stages(configuration *user_config) {
int i; int i;
if(user_config != NULL) { if(user_config != NULL) {
user_config->stages = malloc(sizeof(iter_stage_t) * (size_t) user_config->n_stages); user_config->stages = malloc(sizeof(iter_stage_t) * (size_t) user_config->n_stages);
user_config->t_op_comms = 0;
for(i=0; i<user_config->n_stages; i++) { for(i=0; i<user_config->n_stages; i++) {
user_config->stages[i].array = NULL; user_config->stages[i].array = NULL;
user_config->stages[i].full_array = NULL; user_config->stages[i].full_array = NULL;
...@@ -127,7 +128,7 @@ void free_config(configuration *user_config) { ...@@ -127,7 +128,7 @@ void free_config(configuration *user_config) {
} }
free(user_config->groups); free(user_config->groups);
//free(user_config->stages); //FIXME ERROR de memoria relacionado con la carpeta malleability free(user_config->stages);
free(user_config); free(user_config);
} }
} }
......
...@@ -81,6 +81,7 @@ double process_stage(configuration config_file, iter_stage_t stage, group_data g ...@@ -81,6 +81,7 @@ double process_stage(configuration config_file, iter_stage_t stage, group_data g
//Computo //Computo
case COMP_PI: case COMP_PI:
for(i=0; i < stage.operations; i++) { for(i=0; i < stage.operations; i++) {
if(i%100 == 0) {printf("Test 0.7");}
result += computePiSerial(config_file.granularity); result += computePiSerial(config_file.granularity);
} }
break; break;
......
...@@ -91,7 +91,7 @@ int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_ex ...@@ -91,7 +91,7 @@ int init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_ex
mall->numP = numP; mall->numP = numP;
mall->root = root; mall->root = root;
mall->comm = dup_comm; mall->comm = dup_comm;
mall->thread_comm = thread_comm; // TODO Refactor -- Crear solo si es necesario? mall->thread_comm = thread_comm;
mall->user_comm = comm; mall->user_comm = comm;
mall->name_exec = name_exec; mall->name_exec = name_exec;
...@@ -133,8 +133,8 @@ void free_malleability() { ...@@ -133,8 +133,8 @@ void free_malleability() {
free(dist_s_data); free(dist_s_data);
free(dist_a_data); free(dist_a_data);
//MPI_Comm_free(&(mall->comm)); // TODO Revisar si hace falta? if(mall->comm != MPI_COMM_WORLD) MPI_Comm_free(&(mall->comm));
//MPI_Comm_free(&(mall->thread_comm)); if(mall->thread_comm != MPI_COMM_WORLD) MPI_Comm_free(&(mall->thread_comm));
free(mall); free(mall);
free(mall_conf); free(mall_conf);
......
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