瀏覽代碼

refactoring

Andra Hugo 13 年之前
父節點
當前提交
1c495c7cbd
共有 2 個文件被更改,包括 11 次插入33 次删除
  1. 10 0
      src/core/sched_ctx.c
  2. 1 33
      src/sched_policies/heft.c

+ 10 - 0
src/core/sched_ctx.c

@@ -584,6 +584,16 @@ void starpu_worker_get_sched_condition(unsigned sched_ctx_id, int workerid, pthr
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
 	*sched_mutex = sched_ctx->sched_mutex[workerid];
 	*sched_cond = sched_ctx->sched_cond[workerid];
+
+	/* the tasks concerning changings of the the ctxs were not executed in order */
+	if(!*sched_mutex)
+	{
+		struct _starpu_worker *workerarg = _starpu_get_worker_struct(workerid);
+		*sched_mutex = &workerarg->sched_mutex;
+		*sched_cond = &workerarg->sched_cond;
+		starpu_worker_set_sched_condition(sched_ctx_id, workerid, *sched_mutex, *sched_cond);
+	}
+
 }
 
 void starpu_worker_init_sched_condition(unsigned sched_ctx_id, int workerid)

+ 1 - 33
src/sched_policies/heft.c

@@ -149,14 +149,7 @@ static void heft_pre_exec_hook(struct starpu_task *task)
 	pthread_mutex_t *sched_mutex;
 	pthread_cond_t *sched_cond;
 	starpu_worker_get_sched_condition(sched_ctx_id, workerid, &sched_mutex, &sched_cond);
-	/* the tasks concerning changings of the the ctxs were not executed in order */
-	if(!sched_mutex)
-	{
-		struct _starpu_worker *workerarg = _starpu_get_worker_struct(workerid);
-		sched_mutex = &workerarg->sched_mutex;
-		sched_cond = &workerarg->sched_cond;
-		starpu_worker_set_sched_condition(sched_ctx_id, workerid, sched_mutex, sched_cond);
-	}
+
 	/* Once the task is executing, we can update the predicted amount
 	 * of work. */
 	_STARPU_PTHREAD_MUTEX_LOCK(sched_mutex);
@@ -191,14 +184,6 @@ static void heft_push_task_notify(struct starpu_task *task, int workerid)
 	pthread_mutex_t *sched_mutex;
 	pthread_cond_t *sched_cond;
 	starpu_worker_get_sched_condition(sched_ctx_id, workerid, &sched_mutex, &sched_cond);
-	/* the tasks concerning changings of the the ctxs were not executed in order */
-	if(!sched_mutex)
-	{
-		struct _starpu_worker *workerarg = _starpu_get_worker_struct(workerid);
-		sched_mutex = &workerarg->sched_mutex;
-		sched_cond = &workerarg->sched_cond;
-		starpu_worker_set_sched_condition(sched_ctx_id, workerid, sched_mutex, sched_cond);
-	}
 
 #ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
 	starpu_call_pushed_task_cb(workerid, sched_ctx_id);
@@ -253,14 +238,6 @@ static int push_task_on_best_worker(struct starpu_task *task, int best_workerid,
 	pthread_mutex_t *sched_mutex;
 	pthread_cond_t *sched_cond;
 	starpu_worker_get_sched_condition(sched_ctx_id, best_workerid, &sched_mutex, &sched_cond);
-	/* the tasks concerning changings of the the ctxs were not executed in order */
-	if(!sched_mutex)
-	{
-		struct _starpu_worker *workerarg = _starpu_get_worker_struct(best_workerid);
-		sched_mutex = &workerarg->sched_mutex;
-		sched_cond = &workerarg->sched_cond;
-		starpu_worker_set_sched_condition(sched_ctx_id, best_workerid, sched_mutex, sched_cond);
-	}
 
 #ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
 	starpu_call_pushed_task_cb(best_workerid, sched_ctx_id);
@@ -435,15 +412,6 @@ static int push_conversion_tasks(struct starpu_task *task, unsigned int workerid
 	pthread_mutex_t *sched_mutex;
         pthread_cond_t *sched_cond;
         starpu_worker_get_sched_condition(sched_ctx_id, workerid, &sched_mutex, &sched_cond);
-        /* the tasks concerning changings of the the ctxs were not executed in order */
-        if(!sched_mutex)
-        {
-                struct _starpu_worker *workerarg = _starpu_get_worker_struct(workerid);
-                sched_mutex = &workerarg->sched_mutex;
-                sched_cond = &workerarg->sched_cond;
-                starpu_worker_set_sched_condition(sched_ctx_id, workerid, sched_mutex, sched_cond);
-        }
-
 
 	_STARPU_PTHREAD_MUTEX_LOCK(&sched_mutex[workerid]);
 	for (i = 0; i < task->cl->nbuffers; i++)