From: degomme Date: Thu, 28 Apr 2016 00:01:08 +0000 (+0200) Subject: setup a cleanup routine for mvapich collectives. X-Git-Tag: v3_14~1324 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6d79cb117e4999f3e5c28a1c580b88516bdbe9d6 setup a cleanup routine for mvapich collectives. We allocate some tables at first use that we never released. --- diff --git a/src/include/smpi/smpi_interface.h b/src/include/smpi/smpi_interface.h index e2ea5c52bb..73dd68d737 100644 --- a/src/include/smpi/smpi_interface.h +++ b/src/include/smpi/smpi_interface.h @@ -92,6 +92,8 @@ XBT_PUBLIC_DATA(int (*mpi_coll_barrier_fun)(MPI_Comm comm)); XBT_PUBLIC(void) coll_help(const char *category, s_mpi_coll_description_t * table); XBT_PUBLIC(int) find_coll_description(s_mpi_coll_description_t * table, char *name, const char *desc); +XBT_PUBLIC_DATA(void) (*smpi_coll_cleanup_callback)(void); +XBT_PUBLIC(void) smpi_coll_cleanup_mvapich2(void); extern XBT_PRIVATE double smpi_wtime_sleep; extern XBT_PRIVATE double smpi_iprobe_sleep; extern XBT_PRIVATE double smpi_test_sleep; diff --git a/src/smpi/colls/smpi_mvapich2_selector.c b/src/smpi/colls/smpi_mvapich2_selector.c index b15b5ad4a6..97a876be24 100644 --- a/src/smpi/colls/smpi_mvapich2_selector.c +++ b/src/smpi/colls/smpi_mvapich2_selector.c @@ -1006,3 +1006,32 @@ int smpi_coll_tuned_scatter_mvapich2(void *sendbuf, return (mpi_errno); } + +void smpi_coll_cleanup_mvapich2(){ +int i=0; +if(mv2_alltoall_thresholds_table) + xbt_free(mv2_alltoall_thresholds_table[i]); +xbt_free(mv2_alltoall_thresholds_table); +xbt_free(mv2_size_alltoall_tuning_table); +xbt_free(mv2_alltoall_table_ppn_conf); + +xbt_free(mv2_gather_thresholds_table); + if(mv2_allgather_thresholds_table) +xbt_free(mv2_allgather_thresholds_table[0]); +xbt_free(mv2_size_allgather_tuning_table); +xbt_free(mv2_allgather_table_ppn_conf); +xbt_free(mv2_allgather_thresholds_table); + + +xbt_free(mv2_allgatherv_thresholds_table); +xbt_free(mv2_reduce_thresholds_table); +xbt_free(mv2_red_scat_thresholds_table); +xbt_free(mv2_allreduce_thresholds_table); +xbt_free(mv2_bcast_thresholds_table); +if(mv2_scatter_thresholds_table) + xbt_free(mv2_scatter_thresholds_table[0]); +xbt_free(mv2_scatter_thresholds_table); +xbt_free(mv2_size_scatter_tuning_table); +xbt_free(mv2_scatter_table_ppn_conf); +} + diff --git a/src/smpi/colls/smpi_mvapich2_selector_stampede.h b/src/smpi/colls/smpi_mvapich2_selector_stampede.h index d9824005a9..02cf7acad1 100644 --- a/src/smpi/colls/smpi_mvapich2_selector_stampede.h +++ b/src/smpi/colls/smpi_mvapich2_selector_stampede.h @@ -49,6 +49,8 @@ static void init_mv2_alltoall_tables_stampede(){ int agg_table_sum = 0; mv2_alltoall_tuning_table **table_ptrs = NULL; mv2_alltoall_num_ppn_conf = 3; + if(smpi_coll_cleanup_callback==NULL) + smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; mv2_alltoall_thresholds_table = xbt_malloc(sizeof(mv2_alltoall_tuning_table *) * mv2_alltoall_num_ppn_conf); table_ptrs = xbt_malloc(sizeof(mv2_alltoall_tuning_table *) @@ -593,6 +595,8 @@ MV2_Gather_function_ptr MV2_Gather_intra_node_function = NULL; static void init_mv2_gather_tables_stampede(){ + if(smpi_coll_cleanup_callback==NULL) + smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; mv2_size_gather_tuning_table=7; mv2_gather_thresholds_table = xbt_malloc(mv2_size_gather_tuning_table* sizeof (mv2_gather_tuning_table)); @@ -678,6 +682,8 @@ mv2_allgatherv_tuning_table *mv2_allgatherv_thresholds_table = NULL; static void init_mv2_allgatherv_tables_stampede(){ + if(smpi_coll_cleanup_callback==NULL) + smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; mv2_size_allgatherv_tuning_table = 6; mv2_allgatherv_thresholds_table = xbt_malloc(mv2_size_allgatherv_tuning_table * sizeof (mv2_allgatherv_tuning_table)); @@ -824,6 +830,8 @@ static int MPIR_Allreduce_reduce_shmem_MV2( void *sendbuf, static void init_mv2_allreduce_tables_stampede(){ + if(smpi_coll_cleanup_callback==NULL) + smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; mv2_size_allreduce_tuning_table = 8; mv2_allreduce_thresholds_table = xbt_malloc(mv2_size_allreduce_tuning_table * sizeof (mv2_allreduce_tuning_table)); @@ -1022,6 +1030,8 @@ int mv2_intra_node_knomial_factor = 4; static void init_mv2_bcast_tables_stampede(){ //Stampede, + if(smpi_coll_cleanup_callback==NULL) + smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; mv2_size_bcast_tuning_table=8; mv2_bcast_thresholds_table = xbt_malloc(mv2_size_bcast_tuning_table * sizeof (mv2_bcast_tuning_table)); @@ -1288,6 +1298,8 @@ int (*MV2_Reduce_intra_function)( void *sendbuf, static void init_mv2_reduce_tables_stampede(){ + if(smpi_coll_cleanup_callback==NULL) + smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; /*Stampede*/ mv2_size_reduce_tuning_table = 8; mv2_reduce_thresholds_table = xbt_malloc(mv2_size_reduce_tuning_table * @@ -1530,6 +1542,8 @@ static int MPIR_Reduce_Scatter_Basic_MV2(void *sendbuf, static void init_mv2_reduce_scatter_tables_stampede(){ + if(smpi_coll_cleanup_callback==NULL) + smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; mv2_size_red_scat_tuning_table = 6; mv2_red_scat_thresholds_table = xbt_malloc(mv2_size_red_scat_tuning_table * sizeof (mv2_red_scat_tuning_table)); @@ -1654,7 +1668,9 @@ int MPIR_Scatter_mcst_wrap_MV2(void *sendbuf, static void init_mv2_scatter_tables_stampede(){ - { + if(smpi_coll_cleanup_callback==NULL) + smpi_coll_cleanup_callback=&smpi_coll_cleanup_mvapich2; + int agg_table_sum = 0; int i; mv2_scatter_tuning_table **table_ptrs = NULL; @@ -1961,6 +1977,6 @@ static void init_mv2_scatter_tables_stampede(){ * mv2_size_scatter_tuning_table[i])); } xbt_free(table_ptrs); - } + } diff --git a/src/smpi/smpi_coll.cpp b/src/smpi/smpi_coll.cpp index 9f6d9bf8a2..dcf92403e8 100644 --- a/src/smpi/smpi_coll.cpp +++ b/src/smpi/smpi_coll.cpp @@ -167,6 +167,7 @@ int (*mpi_coll_reduce_fun)(void *buf, void *rbuf, int count, MPI_Datatype dataty int (*mpi_coll_reduce_scatter_fun)(void *sbuf, void *rbuf, int *rcounts,MPI_Datatype dtype,MPI_Op op,MPI_Comm comm); int (*mpi_coll_scatter_fun)(void *sendbuf, int sendcount, MPI_Datatype sendtype,void *recvbuf, int recvcount, MPI_Datatype recvtype,int root, MPI_Comm comm); int (*mpi_coll_barrier_fun)(MPI_Comm comm); +void (*smpi_coll_cleanup_callback)(void); int smpi_coll_tuned_alltoall_ompi2(void *sendbuf, int sendcount, diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index 1da63088db..6bbc1805da 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -50,7 +50,6 @@ int* index_to_process_data = NULL; extern double smpi_total_benched_time; xbt_os_timer_t global_timer; MPI_Comm MPI_COMM_WORLD = MPI_COMM_UNINITIALIZED; - MPI_Errhandler *MPI_ERRORS_RETURN = NULL; MPI_Errhandler *MPI_ERRORS_ARE_FATAL = NULL; MPI_Errhandler *MPI_ERRHANDLER_NULL = NULL; @@ -471,6 +470,8 @@ void smpi_global_destroy(void) if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){ smpi_comm_cleanup_smp(MPI_COMM_WORLD); smpi_comm_cleanup_attributes(MPI_COMM_WORLD); + if(smpi_coll_cleanup_callback!=NULL) + smpi_coll_cleanup_callback(); xbt_free(MPI_COMM_WORLD); } @@ -593,6 +594,7 @@ static void smpi_init_options(){ int barrier_id = find_coll_description(mpi_coll_barrier_description, xbt_cfg_get_string("smpi/barrier"),"barrier"); mpi_coll_barrier_fun = (int (*)(MPI_Comm comm)) mpi_coll_barrier_description[barrier_id].coll; + smpi_coll_cleanup_callback=NULL; smpi_cpu_threshold = xbt_cfg_get_double("smpi/cpu-threshold"); smpi_running_power = xbt_cfg_get_double("smpi/running-power"); smpi_privatize_global_variables = xbt_cfg_get_boolean("smpi/privatize-global-variables");