Просмотр исходного кода

fix initialization and cleaning of priorities in sched_ctx
heteroprio does not support negative priorities

Olivier Aumage лет назад: 8
Родитель
Сommit
86a4e26742
2 измененных файлов с 13 добавлено и 3 удалено
  1. 11 3
      src/core/sched_ctx.c
  2. 2 0
      src/sched_policies/heteroprio.c

+ 11 - 3
src/core/sched_ctx.c

@@ -512,10 +512,16 @@ struct _starpu_sched_ctx* _starpu_create_sched_ctx(struct starpu_sched_policy *p
 	sched_ctx->inheritor = STARPU_NMAX_SCHED_CTXS;
 	sched_ctx->finished_submit = 0;
 	sched_ctx->min_priority_is_set = min_prio_set;
-	if (sched_ctx->min_priority_is_set) sched_ctx->min_priority = min_prio;
-	sched_ctx->max_priority_is_set = max_prio_set;
-	if (sched_ctx->max_priority_is_set) sched_ctx->max_priority = max_prio;
+	if (sched_ctx->min_priority_is_set)
+		sched_ctx->min_priority = min_prio;
+	else
+		sched_ctx->min_priority = 0;
 
+	sched_ctx->max_priority_is_set = max_prio_set;
+	if (sched_ctx->max_priority_is_set)
+		sched_ctx->max_priority = max_prio;
+	else
+		sched_ctx->max_priority = 0;
 
 	_starpu_barrier_counter_init(&sched_ctx->tasks_barrier, 0);
 	_starpu_barrier_counter_init(&sched_ctx->ready_tasks_barrier, 0);
@@ -1052,6 +1058,8 @@ static void _starpu_delete_sched_ctx(struct _starpu_sched_ctx *sched_ctx)
 		sched_ctx->perf_arch.devices = NULL;
 	}
 
+	sched_ctx->min_priority_is_set = 0;
+	sched_ctx->max_priority_is_set = 0;
 	sched_ctx->id = STARPU_NMAX_SCHED_CTXS;
 #ifdef STARPU_HAVE_HWLOC
 	hwloc_bitmap_free(sched_ctx->hwloc_workers_set);

+ 2 - 0
src/sched_policies/heteroprio.c

@@ -159,6 +159,8 @@ static inline void default_init_sched(unsigned sched_ctx_id)
 {
 	int min_prio = starpu_sched_ctx_get_min_priority(sched_ctx_id);
 	int max_prio = starpu_sched_ctx_get_max_priority(sched_ctx_id);
+	STARPU_ASSERT(min_prio >= 0);
+	STARPU_ASSERT(max_prio >= 0);
 	// By default each type of devices uses 1 bucket and no slow factor
 #ifdef STARPU_USE_CPU
 	starpu_heteroprio_set_nb_prios(sched_ctx_id, STARPU_CPU_IDX, max_prio-min_prio+1);