浏览代码

do not let possibility to go out of bounds

Terry Cojean 8 年之前
父节点
当前提交
94e7f6c504
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      examples/sched_ctx/nested_sched_ctxs.c

+ 3 - 1
examples/sched_ctx/nested_sched_ctxs.c

@@ -51,7 +51,9 @@ int parallel_code(int sched_ctx)
 static void sched_ctx_func(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 static void sched_ctx_func(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 {
 {
 	unsigned sched_ctx = (uintptr_t)arg;
 	unsigned sched_ctx = (uintptr_t)arg;
-	tasks_executed[sched_ctx-1]+= parallel_code(sched_ctx);
+	int t = parallel_code(sched_ctx);
+	if (sched_ctx > 0 && sched_ctx < 3)
+		tasks_executed[sched_ctx-1] += t;
 	//printf("w %d executed %d it \n", w, n);
 	//printf("w %d executed %d it \n", w, n);
 }
 }