Browse Source

fix merge trunk@13163

Andra Hugo 10 years ago
parent
commit
97a1e6bc22
1 changed files with 23 additions and 0 deletions
  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;
+}