Kaynağa Gözat

port r17371 from 1.2: fix memory leak in starpu_top

Samuel Thibault 9 yıl önce
ebeveyn
işleme
4b6978eebd
3 değiştirilmiş dosya ile 14 ekleme ve 1 silme
  1. 3 1
      src/core/workers.c
  2. 10 0
      src/top/starpu_top.c
  3. 1 0
      src/top/starpu_top_core.h

+ 3 - 1
src/core/workers.c

@@ -33,6 +33,7 @@
 #include <starpu_task_list.h>
 #include <sched_policies/sched_component.h>
 #include <datawizard/memory_nodes.h>
+#include <top/starpu_top_core.h>
 #include <drivers/mp_common/sink_common.h>
 #include <drivers/scc/driver_scc_common.h>
 
@@ -1503,6 +1504,7 @@ void starpu_shutdown(void)
 
 	_starpu_delete_all_sched_ctxs();
 	_starpu_sched_component_workers_destroy();
+	_starpu_top_shutdown();
 
 	for (worker = 0; worker < _starpu_config.topology.nworkers; worker++)
 		_starpu_worker_deinit(&_starpu_config.workers[worker]);
@@ -1831,7 +1833,7 @@ int starpu_worker_get_bindid(int workerid)
 
 int starpu_bindid_get_workerids(int bindid, int **workerids)
 {
-	if (bindid >= _starpu_config.nbindid)
+	if (bindid >= (int) _starpu_config.nbindid)
 		return 0;
 	*workerids = _starpu_config.bindid_workers[bindid].workerids;
 	return _starpu_config.bindid_workers[bindid].nworkers;

+ 10 - 0
src/top/starpu_top.c

@@ -220,6 +220,16 @@ void starpu_top_init_and_wait(const char* server_name)
 	sem_wait(&starpu_top_wait_for_go);
 }
 
+void _starpu_top_shutdown(void)
+{
+	struct starpu_top_data * cur = starpu_top_first_data, * next;
+	while (cur) {
+		next = cur->next;
+		free(cur);
+		cur = next;
+	}
+}
+
 static
 void starpu_top_enqueue_data(struct starpu_top_data * data)
 {

+ 1 - 0
src/top/starpu_top_core.h

@@ -28,6 +28,7 @@ unsigned long long _starpu_top_timing_timespec_to_ms(const struct timespec *ts);
  * This function returns 1 if starpu_top is initialized. 0 otherwise.
  */
 extern int _starpu_top;
+void _starpu_top_shutdown(void);
 int _starpu_top_status_get(void);
 #define _starpu_top_status_get() _starpu_top