Преглед на файлове

Properly liberate the completion groups by removing the references one by one.

Cédric Augonnet преди 15 години
родител
ревизия
523cf155c9
променени са 2 файла, в които са добавени 17 реда и са изтрити 4 реда
  1. 14 0
      src/core/dependencies/cg.c
  2. 3 4
      src/core/jobs.c

+ 14 - 0
src/core/dependencies/cg.c

@@ -36,7 +36,21 @@ void _starpu_cg_list_init(struct starpu_cg_list_s *list)
 
 void _starpu_cg_list_deinit(struct starpu_cg_list_s *list)
 {
+	unsigned id;
+	for (id = 0; id < list->nsuccs; id++)
+	{
+		starpu_cg_t *cg = list->succ[id];
+
+		/* We remove the reference on the completion group, and
+		 * liberate it if there is no more reference. */		
+		unsigned ntags = STARPU_ATOMIC_ADD(&cg->ntags, -1);
+		if (ntags == 0)
+			free(list->succ[id]);
+	}
+
+#ifdef STARPU_DYNAMIC_DEPS_SIZE
 	free(list->succ);
+#endif
 }
 
 void _starpu_add_successor_to_cg_list(struct starpu_cg_list_s *successors, starpu_cg_t *cg)

+ 3 - 4
src/core/jobs.c

@@ -69,6 +69,8 @@ void _starpu_job_destroy(starpu_job_t j)
 	pthread_mutex_destroy(&j->sync_mutex);
 
 	_starpu_cg_list_deinit(&j->job_successors);
+
+	starpu_job_delete(j);
 }
 
 void _starpu_wait_job(starpu_job_t j)
@@ -133,10 +135,7 @@ void _starpu_handle_job_termination(starpu_job_t j)
 		/* no one is going to synchronize with that task so we release
  		 * the data structures now */
 		if (destroy)
-		{
-			starpu_job_delete(j);
-			free(task);
-		}
+			starpu_task_destroy(task);
 	}
 
 	_starpu_decrement_nsubmitted_tasks();