浏览代码

src/core/sched_ctx: new internal function _starpu_sched_ctx_get_sched_ctx_for_worker_and_job to return a context if the worker is the master of a parallel context, and the job is meant to be executed on this parallel context

Nathalie Furmento 11 年之前
父节点
当前提交
c506a5901d
共有 2 个文件被更改,包括 16 次插入0 次删除
  1. 13 0
      src/core/sched_ctx.c
  2. 3 0
      src/core/sched_ctx.h

+ 13 - 0
src/core/sched_ctx.c

@@ -1796,6 +1796,19 @@ unsigned starpu_sched_ctx_worker_is_master_for_child_ctx(int workerid, unsigned
 
 }
 
+/* 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)
+{
+	struct _starpu_sched_ctx_list *l = NULL;
+	for (l = worker->sched_ctx_list; l; l = l->next)
+	{
+		struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(l->sched_ctx);
+		if (sched_ctx->main_master == worker->workerid && j->task->sched_ctx == sched_ctx->id)
+			return sched_ctx;
+	}
+	return NULL;
+}
+
 void starpu_sched_ctx_revert_task_counters(unsigned sched_ctx_id, double flops)
 {
         _starpu_decrement_nsubmitted_tasks_of_sched_ctx(sched_ctx_id);

+ 3 - 0
src/core/sched_ctx.h

@@ -233,4 +233,7 @@ void _starpu_sched_ctx_post_exec_task_cb(int workerid, struct starpu_task *task,
 
 #endif //STARPU_USE_SC_HYPERVISOR
 
+/* 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);
+
 #endif // __SCHED_CONTEXT_H__