瀏覽代碼

make public a function returning the workers in an array form

Andra Hugo 12 年之前
父節點
當前提交
f4ec3a1ade
共有 3 個文件被更改,包括 13 次插入7 次删除
  1. 6 0
      doc/doxygen/chapters/api/scheduling_contexts.doxy
  2. 1 0
      include/starpu_sched_ctx.h
  3. 6 7
      src/core/sched_ctx.c

+ 6 - 0
doc/doxygen/chapters/api/scheduling_contexts.doxy

@@ -235,6 +235,12 @@ Delete the worker collection of the specified scheduling context
 \ingroup API_Scheduling_Contexts
 Return the worker collection managed by the indicated context
 
+\fn unsigned starpu_sched_ctx_get_workers_list(unsigned sched_ctx_id, int **workerids)
+\ingroup API_Scheduling_Contexts
+Returns the list of workers in the array \p workerids, the returned value is the 
+number of workers. The user should free the \p workerids table after finishing
+using it (it is allocated inside the function with the proper size)
+
 @name Scheduling Context Link with Hypervisor
 \ingroup API_Scheduling_Contexts
 

+ 1 - 0
include/starpu_sched_ctx.h

@@ -48,6 +48,7 @@ void starpu_sched_ctx_stop_task_submission(void);
 
 void starpu_sched_ctx_finished_submit(unsigned sched_ctx_id);
 
+unsigned starpu_sched_ctx_get_workers_list(unsigned sched_ctx_id, int **workerids);
 
 struct starpu_sched_ctx_performance_counters
 {

+ 6 - 7
src/core/sched_ctx.c

@@ -33,8 +33,6 @@ static unsigned _starpu_worker_get_first_free_sched_ctx(struct _starpu_worker *w
 
 static unsigned _starpu_worker_get_sched_ctx_id(struct _starpu_worker *worker, unsigned sched_ctx_id);
 
-static unsigned _get_workers_list(struct _starpu_sched_ctx *sched_ctx, int **workerids);
-
 static void _starpu_worker_gets_into_ctx(unsigned sched_ctx_id, struct _starpu_worker *worker)
 {
 	unsigned worker_sched_ctx_id = _starpu_worker_get_sched_ctx_id(worker, sched_ctx_id);
@@ -205,7 +203,7 @@ static void _starpu_sched_ctx_free_scheduling_data(struct _starpu_sched_ctx *sch
 {
 	int *workerids = NULL;
 
-	unsigned nworkers_ctx = _get_workers_list(sched_ctx, &workerids);
+	unsigned nworkers_ctx = starpu_sched_ctx_get_workers_list(sched_ctx->id, &workerids);
 
 	if(nworkers_ctx > 0 && sched_ctx->sched_policy->remove_workers)
 		sched_ctx->sched_policy->remove_workers(sched_ctx->id, workerids, nworkers_ctx);
@@ -537,7 +535,7 @@ void starpu_sched_ctx_delete(unsigned sched_ctx_id)
 	STARPU_ASSERT(sched_ctx->id != STARPU_NMAX_SCHED_CTXS);
 
 	int *workerids;
-	unsigned nworkers_ctx = _get_workers_list(sched_ctx, &workerids);
+	unsigned nworkers_ctx = starpu_sched_ctx_get_workers_list(sched_ctx->id, &workerids);
 	
 	/*if both of them have all the ressources is pointless*/
 	/*trying to transfer ressources from one ctx to the other*/
@@ -560,7 +558,7 @@ void starpu_sched_ctx_delete(unsigned sched_ctx_id)
 
 	}
 
-	/* workerids is malloc-ed in _get_workers_list, don't forget to free it when
+	/* workerids is malloc-ed in starpu_sched_ctx_get_workers_list, don't forget to free it when
 	   you don't use it anymore */
 	free(workerids);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&changing_ctx_mutex[sched_ctx_id]);
@@ -796,7 +794,7 @@ void _starpu_decrement_nsubmitted_tasks_of_sched_ctx(unsigned sched_ctx_id)
 			if(sched_ctx->id != STARPU_NMAX_SCHED_CTXS)
 			{
 				int *workerids = NULL;
-				unsigned nworkers = _get_workers_list(sched_ctx, &workerids);
+				unsigned nworkers = starpu_sched_ctx_get_workers_list(sched_ctx->id, &workerids);
 				
 				if(nworkers > 0)
 				{
@@ -883,8 +881,9 @@ struct starpu_worker_collection* starpu_sched_ctx_create_worker_collection(unsig
 	return sched_ctx->workers;
 }
 
-static unsigned _get_workers_list(struct _starpu_sched_ctx *sched_ctx, int **workerids)
+unsigned starpu_sched_ctx_get_workers_list(unsigned sched_ctx_id, int **workerids)
 {
+	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
 	struct starpu_worker_collection *workers = sched_ctx->workers;
 	*workerids = (int*)malloc(workers->nworkers*sizeof(int));
 	int worker;