Преглед изворни кода

perfmodel: turn private function which frees internal memory for sampling directories management and call it from tools which do not call starpu_shutdown

Nathalie Furmento пре 10 година
родитељ
комит
602bb833df

+ 7 - 0
doc/doxygen/chapters/api/performance_model.doxy

@@ -206,6 +206,13 @@ Provided by the application
 \ingroup API_Performance_Model
 todo
 
+\fn void starpu_perfmodel_free_sampling_directories(void)
+\ingroup API_Performance_Model
+this function frees internal memory used for sampling directory
+management. It should only be called by an application which is not
+calling starpu_shutdown as this function already calls it. See for
+example <c>tools/starpu_perfmodel_display.c</c>.
+
 \fn int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model)
 \ingroup API_Performance_Model
 loads a given performance model. The model structure has to be

+ 2 - 1
include/starpu_perfmodel.h

@@ -39,7 +39,7 @@ struct starpu_perfmodel_device
 {
 	enum starpu_worker_archtype type;
 	int devid;	/* identifier of the precise device */
-	int ncores;	/* number of execution in parallel, minus 1 */	
+	int ncores;	/* number of execution in parallel, minus 1 */
 };
 
 struct starpu_perfmodel_arch
@@ -141,6 +141,7 @@ struct starpu_perfmodel
 };
 
 void starpu_perfmodel_init(FILE *f, struct starpu_perfmodel *model);
+void starpu_perfmodel_free_sampling_directories(void);
 
 struct starpu_perfmodel_arch *starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id);
 

+ 5 - 1
src/core/perfmodel/perfmodel.c

@@ -504,11 +504,15 @@ void _starpu_create_sampling_directory_if_needed(void)
 	}
 }
 
-void _starpu_free_sampling_directory(void)
+void starpu_perfmodel_free_sampling_directories(void)
 {
 	free(_perf_model_dir);
+	_perf_model_dir = NULL;
 	free(_perf_model_dir_codelet);
+	_perf_model_dir_codelet = NULL;
 	free(_perf_model_dir_bus);
+	_perf_model_dir_bus = NULL;
 	free(_perf_model_dir_debug);
+	_perf_model_dir_debug = NULL;
 	directory_existence_was_tested = 0;
 }

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

@@ -83,7 +83,6 @@ void _starpu_update_perfmodel_history(struct _starpu_job *j, struct starpu_perfm
 int _starpu_perfmodel_create_comb_if_needed(struct starpu_perfmodel_arch* arch);
 
 void _starpu_create_sampling_directory_if_needed(void);
-void _starpu_free_sampling_directory(void);
 
 void _starpu_load_bus_performance_files(void);
 

+ 1 - 1
src/core/perfmodel/perfmodel_history.c

@@ -901,7 +901,7 @@ void _starpu_deinitialize_registered_performance_models(void)
 	STARPU_PTHREAD_RWLOCK_UNLOCK(&registered_models_rwlock);
 	STARPU_PTHREAD_RWLOCK_DESTROY(&registered_models_rwlock);
 	_free_arch_combs();
-	_starpu_free_sampling_directory();
+	starpu_perfmodel_free_sampling_directories();
 }
 
 /* We first try to grab the global lock in read mode to check whether the model

+ 19 - 0
tools/starpu_fxt_data_trace.c

@@ -1,3 +1,21 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2013       Joris Pablo
+ * Copyright (C) 2011-2014  Universite de Bordeaux
+ * Copyright (C) 2014       Centre National de la Recherche Scientifique
+ *
+ * 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
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
 #include <stdio.h>
 #include <config.h>
 #include <starpu.h>
@@ -128,5 +146,6 @@ int main(int argc, char **argv)
 	parse_args(argc, argv);
 	starpu_fxt_write_data_trace(argv[1]);
 	write_gp(argc - 2, argv + 2);
+	starpu_perfmodel_free_sampling_directories();
 	return 0;
 }

+ 9 - 5
tools/starpu_lp2paje.c

@@ -1,6 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2011, 2013-2014  Université de Bordeaux
+ * Copyright (C) 2014                  Centre National de la Recherche Scientifique
  *
  * 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
@@ -22,23 +23,25 @@
 
 #define PROGNAME "starpu_lp2paje"
 
-struct task {
+struct task
+{
 	double start;
 	double stop;
 	int num;
 	int worker;
 };
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
 	int nw, nt;
 	double tmax;
 	int i, w, ww, t, tt, t2;
 	int foo;
 	double bar;
 
-	if (argc != 1) {
-		if (strcmp(argv[1], "-v") == 0
-		 || strcmp(argv[1], "--version") == 0)
+	if (argc != 1)
+	{
+		if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0)
 		{
 			fprintf(stderr, PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n");
 			exit(EXIT_SUCCESS);
@@ -144,5 +147,6 @@ int main(int argc, char *argv[]) {
 		}
 	}
 
+	starpu_perfmodel_free_sampling_directories();
 	return 0;
 }

+ 2 - 1
tools/starpu_perfmodel_display.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011, 2013-2014  Université de Bordeaux
- * Copyright (C) 2011, 2012, 2013  Centre National de la Recherche Scientifique
+ * Copyright (C) 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique
  * Copyright (C) 2011  Télécom-SudParis
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -173,5 +173,6 @@ int main(int argc, char **argv)
 		starpu_perfmodel_print_all(&model, parch, pparameter, footprint, stdout);
         }
 
+	starpu_perfmodel_free_sampling_directories();
 	return 0;
 }

+ 1 - 0
tools/starpu_perfmodel_plot.c

@@ -531,5 +531,6 @@ int main(int argc, char **argv)
 
 	_STARPU_DISP("Gnuplot file <%s> generated\n", gnuplot_file_name);
 
+	starpu_perfmodel_free_sampling_directories();
 	return 0;
 }