Browse Source

move call of sched_ctx->sched_policy->add_workers to the section protected by the ctx_change notification

Olivier Aumage 8 years ago
parent
commit
f7532839e6
3 changed files with 11 additions and 3 deletions
  1. 1 1
      src/core/combined_workers.c
  2. 8 2
      src/core/sched_ctx.c
  3. 2 0
      src/core/sched_ctx.h

+ 1 - 1
src/core/combined_workers.c

@@ -160,7 +160,7 @@ int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[])
 #endif
 	}
 
-	starpu_sched_ctx_add_workers(&combined_worker_id, 1, STARPU_GLOBAL_SCHED_CTX);
+	starpu_sched_ctx_add_combined_workers(&combined_worker_id, 1, STARPU_GLOBAL_SCHED_CTX);
 
 	return new_workerid;
 }

+ 8 - 2
src/core/sched_ctx.c

@@ -348,14 +348,13 @@ static void _starpu_add_workers_to_new_sched_ctx(struct _starpu_sched_ctx *sched
 
 	notify_workers_about_changing_ctx_pending(nworkers, workerids);
 	_do_add_notified_workers(sched_ctx, workerids, nworkers);
-	notify_workers_about_changing_ctx_done(nworkers, workerids);
-
 	if(sched_ctx->sched_policy && sched_ctx->sched_policy->add_workers)
 	{
 		_STARPU_SCHED_BEGIN;
 		sched_ctx->sched_policy->add_workers(sched_ctx->id, workerids, nworkers);
 		_STARPU_SCHED_END;
 	}
+	notify_workers_about_changing_ctx_done(nworkers, workerids);
 }
 
 static void _starpu_remove_workers_from_sched_ctx(struct _starpu_sched_ctx *sched_ctx, int *workerids,
@@ -1387,6 +1386,13 @@ void starpu_sched_ctx_add_workers(int *workers_to_add, unsigned nworkers_to_add,
 	_starpu_sched_ctx_unlock_write(sched_ctx_id);
 }
 
+void starpu_sched_ctx_add_combined_workers(int *combined_workers_to_add, unsigned n_combined_workers_to_add, unsigned sched_ctx_id)
+{
+	_starpu_sched_ctx_lock_write(sched_ctx_id);
+	add_notified_workers(combined_workers_to_add, n_combined_workers_to_add, sched_ctx_id);
+	_starpu_sched_ctx_unlock_write(sched_ctx_id);
+}
+
 void starpu_sched_ctx_remove_workers(int *workers_to_remove, unsigned nworkers_to_remove, unsigned sched_ctx_id)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);

+ 2 - 0
src/core/sched_ctx.h

@@ -230,6 +230,8 @@ void _starpu_sched_ctx_post_exec_task_cb(int workerid, struct starpu_task *task,
 
 #endif //STARPU_USE_SC_HYPERVISOR
 
+void starpu_sched_ctx_add_combined_workers(int *combined_workers_to_add, unsigned n_combined_workers_to_add, unsigned sched_ctx_id);
+
 /* if the worker is the master of a parallel context, and the job is meant to be executed on this parallel context, return a pointer to the context */
 struct _starpu_sched_ctx *__starpu_sched_ctx_get_sched_ctx_for_worker_and_job(struct _starpu_worker *worker, struct _starpu_job *j);