Commit 9516eb5c authored by iker_martin's avatar iker_martin
Browse files

WIP. Encontrado error de memoria entorno a la creacion/liberacion de procesos.

parent 3d004461
...@@ -120,12 +120,12 @@ void malloc_config_arrays(configuration *user_config, int resizes) { ...@@ -120,12 +120,12 @@ void malloc_config_arrays(configuration *user_config, int resizes) {
*/ */
void free_config(configuration *user_config) { void free_config(configuration *user_config) {
if(user_config != NULL) { if(user_config != NULL) {
free(user_config->iters); //free(user_config->iters);
free(user_config->procs); //free(user_config->procs);
free(user_config->factors); //free(user_config->factors);
free(user_config->phy_dist); //free(user_config->phy_dist);
free(user_config); //free(user_config);
} }
} }
......
...@@ -218,12 +218,15 @@ void realloc_results_iters(results_data *results, int needed) { ...@@ -218,12 +218,15 @@ void realloc_results_iters(results_data *results, int needed) {
* Libera toda la memoria asociada con una estructura de resultados. * Libera toda la memoria asociada con una estructura de resultados.
*/ */
void free_results_data(results_data *results) { void free_results_data(results_data *results) {
free(results->spawn_time); if(results != NULL) {
free(results->spawn_thread_time); //free(results->spawn_time);
free(results->sync_time); //free(results->spawn_thread_time);
free(results->async_time); //free(results->sync_time);
//if(results->async_time != NULL)
free(results->iters_time); // free(results->async_time);
free(results->iters_type);
//free(results->iters_time);
//free(results->iters_type);
}
//free(*results); FIXME Borrar //free(*results); FIXME Borrar
} }
...@@ -77,6 +77,15 @@ int main(int argc, char *argv[]) { ...@@ -77,6 +77,15 @@ int main(int argc, char *argv[]) {
MPI_Comm_size(MPI_COMM_WORLD, &numP); MPI_Comm_size(MPI_COMM_WORLD, &numP);
MPI_Comm_rank(MPI_COMM_WORLD, &myId); MPI_Comm_rank(MPI_COMM_WORLD, &myId);
MPI_Comm delete; //FIXME DEBUGGING
MPI_Comm_get_parent(&delete);
if(delete != MPI_COMM_NULL ) {
printf("Hijos salen\n");
MPI_Finalize();
return 0;
}
if(req != MPI_THREAD_MULTIPLE) { if(req != MPI_THREAD_MULTIPLE) {
printf("No se ha obtenido la configuración de hilos necesaria\nSolicitada %d -- Devuelta %d\n", req, MPI_THREAD_MULTIPLE); printf("No se ha obtenido la configuración de hilos necesaria\nSolicitada %d -- Devuelta %d\n", req, MPI_THREAD_MULTIPLE);
} }
...@@ -90,6 +99,7 @@ int main(int argc, char *argv[]) { ...@@ -90,6 +99,7 @@ int main(int argc, char *argv[]) {
MPI_Comm_disconnect(&(group->parents)); //FIXME Volver a poner cuando se arregle MAIN.c MPI_Comm_disconnect(&(group->parents)); //FIXME Volver a poner cuando se arregle MAIN.c
} }
if(group->grp == 0) { if(group->grp == 0) {
init_application(); init_application();
...@@ -102,8 +112,8 @@ int main(int argc, char *argv[]) { ...@@ -102,8 +112,8 @@ int main(int argc, char *argv[]) {
// TODO Que habría que hacer aqui? // TODO Que habría que hacer aqui?
get_benchmark_configuration(&config_file); //No se obtiene bien el archivo get_benchmark_configuration(&config_file); //No se obtiene bien el archivo
get_benchmark_results(&results); //No se obtiene bien el archivo get_benchmark_results(&results); //No se obtiene bien el archivo
set_results_post_reconfig(results, group->grp, config_file->sdr, config_file->adr); set_results_post_reconfig(results, group->grp, config_file->sdr, config_file->adr);
if(config_file->comm_tam) { if(config_file->comm_tam) {
group->compute_comm_array = malloc(config_file->comm_tam * sizeof(char)); group->compute_comm_array = malloc(config_file->comm_tam * sizeof(char));
} }
...@@ -122,9 +132,10 @@ int main(int argc, char *argv[]) { ...@@ -122,9 +132,10 @@ int main(int argc, char *argv[]) {
results->exec_time = MPI_Wtime() - results->exec_start; results->exec_time = MPI_Wtime() - results->exec_start;
} }
print_final_results(); // Pasado este punto ya no pueden escribir los procesos //print_final_results(); // Pasado este punto ya no pueden escribir los procesos
free_application_data();
MPI_Finalize(); MPI_Finalize();
//free_application_data();
return 0; return 0;
} }
...@@ -158,6 +169,9 @@ int work() { ...@@ -158,6 +169,9 @@ int work() {
if(config_file->iters[group->grp] == iter && config_file->resizes != group->grp + 1) if(config_file->iters[group->grp] == iter && config_file->resizes != group->grp + 1)
state = malleability_checkpoint(); state = malleability_checkpoint();
MPI_Finalize();
exit(0);
iter = 0; iter = 0;
while(state == MAL_DIST_PENDING || state == MAL_SPAWN_PENDING) { while(state == MAL_DIST_PENDING || state == MAL_SPAWN_PENDING) {
iterate(matrix, config_file->matrix_tam, state); iterate(matrix, config_file->matrix_tam, state);
...@@ -353,14 +367,15 @@ void free_application_data() { ...@@ -353,14 +367,15 @@ void free_application_data() {
free(group->async_array); free(group->async_array);
} }
free_malleability();
free_config(config_file);
if(group->grp == 0) { //FIXME Revisar porque cuando es diferente a 0 no funciona if(group->grp == 0) { //FIXME Revisar porque cuando es diferente a 0 no funciona
//free_config(config_file); free_results_data(results);
//free_results_data(results); //free(results);
} }
free(group); free(group);
free_malleability();
free(results);
} }
......
...@@ -32,9 +32,9 @@ typedef struct { ...@@ -32,9 +32,9 @@ typedef struct {
int comm_type; int comm_type;
int comm_threaded; int comm_threaded;
int grp;
configuration *config_file; configuration *config_file;
results_data *results; results_data *results;
int grp;
} malleability_config_t; } malleability_config_t;
typedef struct { typedef struct {
...@@ -67,14 +67,15 @@ void init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_e ...@@ -67,14 +67,15 @@ void init_malleability(int myId, int numP, int root, MPI_Comm comm, char *name_e
rep_a_data = (malleability_data_t *) malloc(sizeof(malleability_data_t)); rep_a_data = (malleability_data_t *) malloc(sizeof(malleability_data_t));
dist_a_data = (malleability_data_t *) malloc(sizeof(malleability_data_t)); dist_a_data = (malleability_data_t *) malloc(sizeof(malleability_data_t));
MPI_Comm_dup(comm, &dup_comm); //MPI_Comm_dup(comm, &dup_comm);
MPI_Comm_dup(comm, &thread_comm); //MPI_Comm_dup(comm, &thread_comm);
mall->comm = comm;
mall->myId = myId; mall->myId = myId;
mall->numP = numP; mall->numP = numP;
mall->root = root; mall->root = root;
mall->comm = dup_comm; //mall->comm = dup_comm;
mall->comm = thread_comm; // TODO Refactor -- Crear solo si es necesario? //mall->comm = thread_comm; // TODO Refactor -- Crear solo si es necesario?
mall->name_exec = name_exec; mall->name_exec = name_exec;
rep_s_data->entries = 0; rep_s_data->entries = 0;
...@@ -133,6 +134,7 @@ int malleability_checkpoint() { ...@@ -133,6 +134,7 @@ int malleability_checkpoint() {
//if(CHECK_RMS()) {return MAL_DENIED;} //if(CHECK_RMS()) {return MAL_DENIED;}
state = spawn_step(); state = spawn_step();
return MAL_DIST_COMPLETED;
if (state == MAL_SPAWN_COMPLETED){ if (state == MAL_SPAWN_COMPLETED){
state = start_redistribution(); state = start_redistribution();
...@@ -359,9 +361,11 @@ void Children_init() { ...@@ -359,9 +361,11 @@ void Children_init() {
mall_conf->config_file = recv_config_file(mall->root, mall->intercomm); mall_conf->config_file = recv_config_file(mall->root, mall->intercomm);
mall_conf->results = (results_data *) malloc(sizeof(results_data)); mall_conf->results = (results_data *) malloc(sizeof(results_data));
init_results_data(mall_conf->results, mall_conf->config_file->resizes - 1, RESULTS_INIT_DATA_QTY); init_results_data(mall_conf->results, mall_conf->config_file->resizes, RESULTS_INIT_DATA_QTY);
if(dist_a_data->entries || rep_a_data->entries) { // Recibir datos asincronos if(dist_a_data->entries || rep_a_data->entries) { // Recibir datos asincronos
printf("HIJOS NO ASYNC\n"); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
comm_data_info(rep_a_data, dist_a_data, MALLEABILITY_CHILDREN, mall->myId, root_parents, mall->intercomm); comm_data_info(rep_a_data, dist_a_data, MALLEABILITY_CHILDREN, mall->myId, root_parents, mall->intercomm);
if(mall_conf->comm_type == MAL_USE_NORMAL || mall_conf->comm_type == MAL_USE_IBARRIER || mall_conf->comm_type == MAL_USE_POINT) { if(mall_conf->comm_type == MAL_USE_NORMAL || mall_conf->comm_type == MAL_USE_IBARRIER || mall_conf->comm_type == MAL_USE_POINT) {
...@@ -374,6 +378,7 @@ void Children_init() { ...@@ -374,6 +378,7 @@ void Children_init() {
} }
if(dist_s_data->entries || rep_s_data->entries) { // Recibir datos sincronos if(dist_s_data->entries || rep_s_data->entries) { // Recibir datos sincronos
printf("HIJOS NO SYNC\n"); fflush(stdout); MPI_Barrier(MPI_COMM_WORLD);
comm_data_info(rep_s_data, dist_s_data, MALLEABILITY_CHILDREN, mall->myId, root_parents, mall->intercomm); comm_data_info(rep_s_data, dist_s_data, MALLEABILITY_CHILDREN, mall->myId, root_parents, mall->intercomm);
recv_data(numP_parents, dist_s_data, 0); recv_data(numP_parents, dist_s_data, 0);
...@@ -387,6 +392,7 @@ void Children_init() { ...@@ -387,6 +392,7 @@ void Children_init() {
//rep_s_data->arrays[i] = (void *) aux; //rep_s_data->arrays[i] = (void *) aux;
} }
} }
// Guardar los resultados de esta transmision // Guardar los resultados de esta transmision
recv_results(mall_conf->results, mall->root, mall_conf->config_file->resizes, mall->intercomm); recv_results(mall_conf->results, mall->root, mall_conf->config_file->resizes, mall->intercomm);
...@@ -445,7 +451,6 @@ int start_redistribution() { ...@@ -445,7 +451,6 @@ int start_redistribution() {
if(mall_conf->comm_type == MAL_USE_THREAD) { if(mall_conf->comm_type == MAL_USE_THREAD) {
return thread_creation(); return thread_creation();
} else { } else {
// send_async(group->async_array, config_file->adr, group->myId, group->numP, ROOT, group->children, group->numS, comm_req, config_file->aib);
send_data(mall->numC, dist_a_data, MALLEABILITY_USE_ASYNCHRONOUS); send_data(mall->numC, dist_a_data, MALLEABILITY_USE_ASYNCHRONOUS);
return MAL_DIST_PENDING; return MAL_DIST_PENDING;
} }
......
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