Browse Source

src/core: free workers's list of contexts

Nathalie Furmento 12 years ago
parent
commit
3bc625b345
3 changed files with 12 additions and 2 deletions
  1. 6 0
      src/core/sched_ctx.c
  2. 4 1
      src/core/sched_ctx.h
  3. 2 1
      src/core/workers.c

+ 6 - 0
src/core/sched_ctx.c

@@ -660,6 +660,12 @@ void _starpu_init_sched_ctx_for_worker(unsigned workerid)
 	return;
 }
 
+void _starpu_delete_sched_ctx_for_worker(unsigned workerid)
+{
+	struct _starpu_worker *worker = _starpu_get_worker_struct(workerid);
+	free(worker->sched_ctx);
+}
+
 /* sched_ctx aren't necessarly one next to another */
 /* for eg when we remove one its place is free */
 /* when we add  new one we reuse its place */

+ 4 - 1
src/core/sched_ctx.h

@@ -100,9 +100,12 @@ struct _starpu_machine_config;
 /* init sched_ctx_id of all contextes*/
 void _starpu_init_all_sched_ctxs(struct _starpu_machine_config *config);
 
-/* init the list of contextes of the worker */
+/* init the list of contexts of the worker */
 void _starpu_init_sched_ctx_for_worker(unsigned workerid);
 
+/* free the list of contexts of the worker */
+void _starpu_delete_sched_ctx_for_worker(unsigned workerid);
+
 /* allocate all structures belonging to a context */
 struct _starpu_sched_ctx*  _starpu_create_sched_ctx(const char *policy_name, int *workerid, int nworkerids, unsigned is_init_sched, const char *sched_name);
 

+ 2 - 1
src/core/workers.c

@@ -879,8 +879,9 @@ static void _starpu_terminate_workers(struct _starpu_machine_config *pconfig)
 #endif
 		}
 
-out:		
+out:
 		STARPU_ASSERT(starpu_task_list_empty(&worker->local_tasks));
+		_starpu_delete_sched_ctx_for_worker(workerid);
 		_starpu_job_list_delete(worker->terminated_jobs);
 	}
 }