Browse Source

Fix memory release in starpu_perfmodel_*

Samuel Thibault 5 years ago
parent
commit
4ec07ae93a

+ 3 - 3
include/starpu_perfmodel.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2011-2014,2016                           Inria
  * Copyright (C) 2011-2014,2016                           Inria
- * Copyright (C) 2009-2019                                Université de Bordeaux
+ * Copyright (C) 2009-2020                                Université de Bordeaux
  * Copyright (C) 2010-2017, 2019                                CNRS
  * Copyright (C) 2010-2017, 2019                                CNRS
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2011                                     Télécom-SudParis
  * Copyright (C) 2011                                     Télécom-SudParis
@@ -340,12 +340,12 @@ void starpu_perfmodel_get_model_path(const char *symbol, char *path, size_t maxl
 void starpu_perfmodel_dump_xml(FILE *output, struct starpu_perfmodel *model);
 void starpu_perfmodel_dump_xml(FILE *output, struct starpu_perfmodel *model);
 
 
 /**
 /**
-   Free internal memory used for sampling directory
+   Free internal memory used for sampling
    management. It should only be called by an application which is not
    management. It should only be called by an application which is not
    calling starpu_shutdown() as this function already calls it. See for
    calling starpu_shutdown() as this function already calls it. See for
    example <c>tools/starpu_perfmodel_display.c</c>.
    example <c>tools/starpu_perfmodel_display.c</c>.
 */
 */
-void starpu_perfmodel_free_sampling_directories(void);
+void starpu_perfmodel_free_sampling(void);
 
 
 /**
 /**
    Return the architecture type of the worker \p workerid.
    Return the architecture type of the worker \p workerid.

+ 3 - 2
src/core/perfmodel/perfmodel.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2011,2012,2014,2016,2017                 Inria
  * Copyright (C) 2011,2012,2014,2016,2017                 Inria
- * Copyright (C) 2008-2019                                Université de Bordeaux
+ * Copyright (C) 2008-2020                                Université de Bordeaux
  * Copyright (C) 2010-2017, 2019                          CNRS
  * Copyright (C) 2010-2017, 2019                          CNRS
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2011                                     Télécom-SudParis
  * Copyright (C) 2011                                     Télécom-SudParis
@@ -554,7 +554,7 @@ void _starpu_create_sampling_directory_if_needed(void)
 	}
 	}
 }
 }
 
 
-void starpu_perfmodel_free_sampling_directories(void)
+void starpu_perfmodel_free_sampling(void)
 {
 {
 	free(_perf_model_dir);
 	free(_perf_model_dir);
 	_perf_model_dir = NULL;
 	_perf_model_dir = NULL;
@@ -565,6 +565,7 @@ void starpu_perfmodel_free_sampling_directories(void)
 	free(_perf_model_dir_debug);
 	free(_perf_model_dir_debug);
 	_perf_model_dir_debug = NULL;
 	_perf_model_dir_debug = NULL;
 	directory_existence_was_tested = 0;
 	directory_existence_was_tested = 0;
+	_starpu_free_arch_combs();
 }
 }
 
 
 
 

+ 3 - 1
src/core/perfmodel/perfmodel.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2011-2014,2016,2017                      Inria
  * Copyright (C) 2011-2014,2016,2017                      Inria
- * Copyright (C) 2008-2019                                Université de Bordeaux
+ * Copyright (C) 2008-2020                                Université de Bordeaux
  * Copyright (C) 2010-2015,2017,2019                      CNRS
  * Copyright (C) 2010-2015,2017,2019                      CNRS
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2011                                     Télécom-SudParis
  * Copyright (C) 2011                                     Télécom-SudParis
@@ -105,6 +105,8 @@ void _starpu_simgrid_get_platform_path(int version, char *path, size_t maxlen);
 
 
 void _starpu_perfmodel_realloc(struct starpu_perfmodel *model, int nb);
 void _starpu_perfmodel_realloc(struct starpu_perfmodel *model, int nb);
 
 
+void _starpu_free_arch_combs(void);
+
 #if defined(STARPU_HAVE_HWLOC)
 #if defined(STARPU_HAVE_HWLOC)
 hwloc_topology_t _starpu_perfmodel_get_hwtopology();
 hwloc_topology_t _starpu_perfmodel_get_hwtopology();
 #endif
 #endif

+ 3 - 4
src/core/perfmodel/perfmodel_history.c

@@ -173,7 +173,7 @@ int starpu_perfmodel_arch_comb_add(int ndevices, struct starpu_perfmodel_device*
 	return comb;
 	return comb;
 }
 }
 
 
-static 	void _free_arch_combs(void)
+void _starpu_free_arch_combs(void)
 {
 {
 	int i;
 	int i;
 	STARPU_PTHREAD_RWLOCK_WRLOCK(&arch_combs_mutex);
 	STARPU_PTHREAD_RWLOCK_WRLOCK(&arch_combs_mutex);
@@ -1340,8 +1340,7 @@ void _starpu_deinitialize_registered_performance_models(void)
 
 
 	STARPU_PTHREAD_RWLOCK_UNLOCK(&registered_models_rwlock);
 	STARPU_PTHREAD_RWLOCK_UNLOCK(&registered_models_rwlock);
 	STARPU_PTHREAD_RWLOCK_DESTROY(&registered_models_rwlock);
 	STARPU_PTHREAD_RWLOCK_DESTROY(&registered_models_rwlock);
-	_free_arch_combs();
-	starpu_perfmodel_free_sampling_directories();
+	starpu_perfmodel_free_sampling();
 }
 }
 
 
 /* We first try to grab the global lock in read mode to check whether the model
 /* We first try to grab the global lock in read mode to check whether the model
@@ -2095,7 +2094,7 @@ struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_arch(struct sta
 	return &model->state->per_arch[comb][impl];
 	return &model->state->per_arch[comb][impl];
 }
 }
 
 
-struct starpu_perfmodel_per_arch *_starpu_perfmodel_get_model_per_devices(struct starpu_perfmodel *model, int impl, va_list varg_list)
+static struct starpu_perfmodel_per_arch *_starpu_perfmodel_get_model_per_devices(struct starpu_perfmodel *model, int impl, va_list varg_list)
 {
 {
 	struct starpu_perfmodel_arch arch;
 	struct starpu_perfmodel_arch arch;
 	va_list varg_list_copy;
 	va_list varg_list_copy;

+ 1 - 1
src/core/workers.c

@@ -1560,7 +1560,7 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
 	/* sink doesn't exit even if no worker discorvered */
 	/* sink doesn't exit even if no worker discorvered */
 	if (ret && !is_a_sink)
 	if (ret && !is_a_sink)
 	{
 	{
-		starpu_perfmodel_free_sampling_directories();
+		starpu_perfmodel_free_sampling();
 		STARPU_PTHREAD_MUTEX_LOCK(&init_mutex);
 		STARPU_PTHREAD_MUTEX_LOCK(&init_mutex);
 		init_count--;
 		init_count--;
 
 

+ 2 - 2
tools/starpu_fxt_data_trace.c

@@ -2,7 +2,7 @@
  *
  *
  * Copyright (C) 2013                                     Joris Pablo
  * Copyright (C) 2013                                     Joris Pablo
  * Copyright (C) 2014,2015,2017                           CNRS
  * Copyright (C) 2014,2015,2017                           CNRS
- * Copyright (C) 2011-2014,2016,2019                      Université de Bordeaux
+ * Copyright (C) 2011-2014,2016,2019-2020                 Université de Bordeaux
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
  * it under the terms of the GNU Lesser General Public License as published by
@@ -167,6 +167,6 @@ int main(int argc, char **argv)
 	if (ret) return ret;
 	if (ret) return ret;
 	starpu_fxt_write_data_trace(argv[1]);
 	starpu_fxt_write_data_trace(argv[1]);
 	write_gp(argc - 2, argv + 2);
 	write_gp(argc - 2, argv + 2);
-	starpu_perfmodel_free_sampling_directories();
+	starpu_perfmodel_free_sampling();
 	return 0;
 	return 0;
 }
 }

+ 2 - 2
tools/starpu_perfmodel_display.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2009-2014,2017,2019                      Université de Bordeaux
+ * Copyright (C) 2009-2014,2017,2019-2020                 Université de Bordeaux
  * Copyright (C) 2011,2012                                Inria
  * Copyright (C) 2011,2012                                Inria
  * Copyright (C) 2010-2017                                CNRS
  * Copyright (C) 2010-2017                                CNRS
  * Copyright (C) 2011                                     Télécom-SudParis
  * Copyright (C) 2011                                     Télécom-SudParis
@@ -190,6 +190,6 @@ int main(int argc, char **argv)
 		starpu_perfmodel_unload_model(&model);
 		starpu_perfmodel_unload_model(&model);
         }
         }
 
 
-	starpu_perfmodel_free_sampling_directories();
+	starpu_perfmodel_free_sampling();
 	return 0;
 	return 0;
 }
 }

+ 2 - 2
tools/starpu_perfmodel_plot.c

@@ -2,7 +2,7 @@
  *
  *
  * Copyright (C) 2011,2012,2015                           Inria
  * Copyright (C) 2011,2012,2015                           Inria
  * Copyright (C) 2011-2017                                CNRS
  * Copyright (C) 2011-2017                                CNRS
- * Copyright (C) 2011-2014,2017                           Université de Bordeaux
+ * Copyright (C) 2011-2014,2017,2020                      Université de Bordeaux
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2011                                     Télécom-SudParis
  * Copyright (C) 2011                                     Télécom-SudParis
  *
  *
@@ -541,6 +541,6 @@ int main(int argc, char **argv)
 			_STARPU_DISP("Gnuplot file <%s> generated\n", gnuplot_file_name);
 			_STARPU_DISP("Gnuplot file <%s> generated\n", gnuplot_file_name);
 		}
 		}
 	}
 	}
-	starpu_perfmodel_free_sampling_directories();
+	starpu_perfmodel_free_sampling();
 	return ret;
 	return ret;
 }
 }