Просмотр исходного кода

factorize init of worker_collection

Andra Hugo лет назад: 12
Родитель
Сommit
7eddde2a77
3 измененных файлов с 7 добавлено и 5 удалено
  1. 1 1
      include/starpu_sched_ctx.h
  2. 1 2
      src/core/sched_ctx.c
  3. 5 2
      src/worker_collection/worker_list.c

+ 1 - 1
include/starpu_sched_ctx.h

@@ -53,7 +53,7 @@ struct starpu_sched_ctx_worker_collection
 	/* remove an element from the collection */
 	int (*remove)(struct starpu_sched_ctx_worker_collection *workers, int worker);
 	/* initialize the structure */
-	void* (*init)(struct starpu_sched_ctx_worker_collection *workers);
+	void (*init)(struct starpu_sched_ctx_worker_collection *workers);
 	/* free the structure */
 	void (*deinit)(struct starpu_sched_ctx_worker_collection *workers);
 	/* initialize the cursor if there is one */

+ 1 - 2
src/core/sched_ctx.c

@@ -234,8 +234,7 @@ struct _starpu_sched_ctx*  _starpu_create_sched_ctx(const char *policy_name, int
 	_starpu_init_sched_policy(config, sched_ctx, policy_name);
 
 	/* construct the collection of workers(list/tree/etc.) */
-	sched_ctx->workers->workerids = sched_ctx->workers->init(sched_ctx->workers);
-	sched_ctx->workers->nworkers = 0;
+	sched_ctx->workers->init(sched_ctx->workers);
 
 	/* after having an worker_collection on the ressources add them */
 	_starpu_add_workers_to_sched_ctx(sched_ctx, workerids, nworkers_ctx, NULL, NULL);

+ 5 - 2
src/worker_collection/worker_list.c

@@ -119,12 +119,15 @@ static void _init_workers(int *workerids)
 	return;
 }
 
-static void* list_init(struct starpu_sched_ctx_worker_collection *workers)
+static void list_init(struct starpu_sched_ctx_worker_collection *workers)
 {
 	int *workerids = (int*)malloc(STARPU_NMAXWORKERS * sizeof(int));
 	_init_workers(workerids);
 
-	return (void*)workerids;
+	workers->workerids = (void*)workerids;
+	workers->nworkers = 0;
+
+	return;
 }
 
 static void list_deinit(struct starpu_sched_ctx_worker_collection *workers)