浏览代码

fix merge trunk@13163

Andra Hugo 10 年之前
父节点
当前提交
97a1e6bc22
共有 1 个文件被更改,包括 23 次插入0 次删除
  1. 23 0
      src/core/sched_ctx.c

+ 23 - 0
src/core/sched_ctx.c

@@ -2166,3 +2166,26 @@ struct starpu_perfmodel_arch * _starpu_sched_ctx_get_perf_archtype(unsigned sche
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
 	return &sched_ctx->perf_arch;
 }
+
+int starpu_sched_ctx_get_worker_rank(unsigned sched_ctx_id)
+{
+	int idx = 0;
+	int curr_workerid = starpu_worker_get_id();
+	int worker;
+	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
+	struct starpu_worker_collection *workers = sched_ctx->workers;
+
+	struct starpu_sched_ctx_iterator it;
+	if(workers->init_iterator)
+		workers->init_iterator(workers, &it);
+
+	while(workers->has_next(workers, &it))
+	{
+		worker = workers->get_next(workers, &it);
+		if(worker == curr_workerid)
+			return idx;
+		idx++;
+	}
+
+	return -1;
+}