From: degomme Date: Mon, 25 Apr 2016 13:35:02 +0000 (+0200) Subject: leaks -- with smp algos X-Git-Tag: v3_13~34^2~10^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/21446da234b79358c6f7ed918e582e7e5a36d8b3 leaks -- with smp algos --- diff --git a/src/smpi/colls/reduce-mvapich-knomial.c b/src/smpi/colls/reduce-mvapich-knomial.c index cbed125111..7ec5c64797 100644 --- a/src/smpi/colls/reduce-mvapich-knomial.c +++ b/src/smpi/colls/reduce-mvapich-knomial.c @@ -215,6 +215,8 @@ int smpi_coll_tuned_reduce_mvapich2_knomial ( COLL_TAG_REDUCE,comm); smpi_mpi_waitall(1, &send_request, &status); + + smpi_free_tmp_buffer((void *)((char*)recvbuf + true_lb)); } /* --END ERROR HANDLING-- */ diff --git a/src/smpi/colls/reduce-mvapich-two-level.c b/src/smpi/colls/reduce-mvapich-two-level.c index 306bec9a9c..be67ddd958 100644 --- a/src/smpi/colls/reduce-mvapich-two-level.c +++ b/src/smpi/colls/reduce-mvapich-two-level.c @@ -233,6 +233,7 @@ int smpi_coll_tuned_reduce_mvapich2_two_level( void *sendbuf, intra_node_root, shmem_comm); } } else { + smpi_free_tmp_buffer((void *) ((char *) tmp_buf + true_lb)); tmp_buf = in_buf; } @@ -286,15 +287,23 @@ int smpi_coll_tuned_reduce_mvapich2_two_level( void *sendbuf, smpi_mpi_send(tmp_buf, count, datatype, root, COLL_TAG_REDUCE+1, comm); } - if ((local_rank != 0) && (root == my_rank)) { smpi_mpi_recv(recvbuf, count, datatype, leader_of_root, COLL_TAG_REDUCE+1, comm, MPI_STATUS_IGNORE); } + smpi_free_tmp_buffer((void *) ((char *) tmp_buf + true_lb)); + + if (leader_comm_rank == leader_root) { + if (my_rank != root || (my_rank == root && tmp_buf == recvbuf)) { + smpi_free_tmp_buffer(in_buf); + } + } } + + fn_exit: return mpi_errno; } diff --git a/src/smpi/colls/reduce-scatter-gather.c b/src/smpi/colls/reduce-scatter-gather.c index 57161ff817..98f2a097fa 100644 --- a/src/smpi/colls/reduce-scatter-gather.c +++ b/src/smpi/colls/reduce-scatter-gather.c @@ -21,7 +21,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, int recv_idx, last_idx = 0, newdst; int dst, send_cnt, recv_cnt, newroot, newdst_tree_root; int newroot_tree_root, new_count; - int tag = COLL_TAG_REDUCE; + int tag = COLL_TAG_REDUCE,temporary_buffer=0; void *send_ptr, *recv_ptr, *tmp_buf; cnts = NULL; @@ -40,6 +40,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, /* If I'm not the root, then my recvbuf may not be valid, therefore I have to allocate a temporary one */ if (rank != root && !recvbuf) { + temporary_buffer=1; recvbuf = (void *)smpi_get_tmp_recvbuffer(count * extent); } /* find nearest power-of-two less than or equal to comm_size */ @@ -401,6 +402,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, } if (tmp_buf) smpi_free_tmp_buffer(tmp_buf); + if(temporary_buffer==1) smpi_free_tmp_buffer(recvbuf); if (cnts) free(cnts); if (disps) diff --git a/src/smpi/private.h b/src/smpi/private.h index b5f27432ad..746abc8fa2 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -262,6 +262,8 @@ XBT_PRIVATE MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key); XBT_PRIVATE int smpi_comm_dup(MPI_Comm comm, MPI_Comm* newcomm); XBT_PRIVATE void smpi_comm_use(MPI_Comm comm); XBT_PRIVATE void smpi_comm_unuse(MPI_Comm comm); +XBT_PRIVATE void smpi_comm_cleanup_attributes(MPI_Comm comm); +XBT_PRIVATE void smpi_comm_cleanup_smp(MPI_Comm comm); XBT_PRIVATE void smpi_comm_set_leaders_comm(MPI_Comm comm, MPI_Comm leaders); XBT_PRIVATE void smpi_comm_set_intra_comm(MPI_Comm comm, MPI_Comm leaders); XBT_PRIVATE int* smpi_comm_get_non_uniform_map(MPI_Comm comm); diff --git a/src/smpi/smpi_comm.cpp b/src/smpi/smpi_comm.cpp index 4e45a21549..e5370df89d 100644 --- a/src/smpi/smpi_comm.cpp +++ b/src/smpi/smpi_comm.cpp @@ -314,12 +314,22 @@ void smpi_comm_use(MPI_Comm comm){ comm->refcount++; } -void smpi_comm_unuse(MPI_Comm comm){ - if (comm == MPI_COMM_UNINITIALIZED) - comm = smpi_process_comm_world(); - comm->refcount--; - smpi_group_unuse(comm->group); - if(comm->refcount==0){ +void smpi_comm_cleanup_attributes(MPI_Comm comm){ + if(comm->attributes !=NULL){ + xbt_dict_cursor_t cursor = NULL; + int* key; + void * value; + int flag; + xbt_dict_foreach(comm->attributes, cursor, key, value){ + smpi_comm_key_elem elem = + static_cast(xbt_dict_get_or_null(smpi_comm_keyvals, (const char*)key)); + if(elem && elem->delete_fn) + elem->delete_fn(comm, *key, value, &flag); + } + } +} + +void smpi_comm_cleanup_smp(MPI_Comm comm){ if(comm->intra_comm != MPI_COMM_NULL) smpi_comm_unuse(comm->intra_comm); if(comm->leaders_comm != MPI_COMM_NULL) @@ -328,18 +338,17 @@ void smpi_comm_unuse(MPI_Comm comm){ xbt_free(comm->non_uniform_map); if(comm->leaders_map !=NULL) xbt_free(comm->leaders_map); - if(comm->attributes !=NULL){ - xbt_dict_cursor_t cursor = NULL; - int* key; - void * value; - int flag; - xbt_dict_foreach(comm->attributes, cursor, key, value){ - smpi_comm_key_elem elem = - static_cast(xbt_dict_get_or_null(smpi_comm_keyvals, (const char*)key)); - if(elem && elem->delete_fn) - elem->delete_fn(comm, *key, value, &flag); - } - } +} + +void smpi_comm_unuse(MPI_Comm comm){ + if (comm == MPI_COMM_UNINITIALIZED) + comm = smpi_process_comm_world(); + comm->refcount--; + smpi_group_unuse(comm->group); + + if(comm->refcount==0){ + smpi_comm_cleanup_smp(comm); + smpi_comm_cleanup_attributes(comm); xbt_free(comm); } } @@ -467,9 +476,13 @@ void smpi_comm_init_smp(MPI_Comm comm){ for (i=0; i< leader_group_size;i++) smpi_group_set_mapping(leaders_group, leader_list[i], i); - leader_comm = smpi_comm_new(leaders_group, NULL); - if(smpi_comm_get_leaders_comm(comm)==MPI_COMM_NULL) + if(smpi_comm_get_leaders_comm(comm)==MPI_COMM_NULL){ + leader_comm = smpi_comm_new(leaders_group, NULL); smpi_comm_set_leaders_comm(comm, leader_comm); + }else{ + leader_comm=smpi_comm_get_leaders_comm(comm); + smpi_group_unuse(leaders_group); + } smpi_process_set_comm_intra(comm_intra); } diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index 6ef4b1959b..76cd8d78ac 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -466,8 +466,12 @@ void smpi_global_destroy(void) xbt_free(process_data); process_data = NULL; - if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED) + if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){ + smpi_comm_cleanup_smp(MPI_COMM_WORLD); + smpi_comm_cleanup_attributes(MPI_COMM_WORLD); xbt_free(MPI_COMM_WORLD); + } + MPI_COMM_WORLD = MPI_COMM_NULL; xbt_free(index_to_process_data);