Browse Source

scheduler: revert 9247 and add functions to set and get task
priorities per scheduling context.

The functions starpu_sched_get/set_min/max_priority behave as the
functions defined on the scheduler context with the global context.

Nathalie Furmento 12 years ago
parent
commit
b08a2c55e0

+ 38 - 9
doc/chapters/api.texi

@@ -2027,11 +2027,11 @@ process the task). Otherwise, @code{starpu_task_submit} returns immediately.
 @item @code{int priority} (optional) (default: @code{STARPU_DEFAULT_PRIO})
 This field indicates a level of priority for the task. This is an integer value
 that must be set between the return values of the
-@code{starpu_task_get_min_priority} function for the least important tasks,
-and that of the @code{starpu_task_get_max_priority} for the most important
+@code{starpu_sched_get_min_priority} function for the least important tasks,
+and that of the @code{starpu_sched_get_max_priority} for the most important
 tasks (included). The @code{STARPU_MIN_PRIO} and @code{STARPU_MAX_PRIO} macros
 are provided for convenience and respectively returns value of
-@code{starpu_task_get_min_priority} and @code{starpu_task_get_max_priority}.
+@code{starpu_sched_get_min_priority} and @code{starpu_sched_get_max_priority}.
 Default priority is @code{STARPU_DEFAULT_PRIO}, which is always defined as 0 in
 order to allow static task initialization.  Scheduling strategies that take
 priorities into account can use this parameter to take better scheduling
@@ -3530,6 +3530,7 @@ they are taken in ID order.
 
 @node Scheduling Contexts
 @section Scheduling Contexts
+
 StarPU permits on one hand grouping workers in combined workers in order to execute a parallel task and on the other hand grouping tasks in bundles that will be executed by a single specified worker.
 In contrast when we group workers in scheduling contexts we submit starpu tasks to them and we schedule them with the policy assigned to the context.
 Scheduling contexts can be created, deleted and modified dynamically.
@@ -3617,6 +3618,34 @@ Return the number of workers managed by the specified contexts
 Return the number of workers shared by two contexts
 @end deftypefun
 
+@deftypefun void starpu_sched_ctx_set_min_priority (unsigned @var{sched_ctx_id}, int @var{min_prio})
+Defines the minimum task priority level supported by the scheduling
+policy of the given scheduler context. The
+default minimum priority level is the same as the default priority level which
+is 0 by convention.  The application may access that value by calling the
+@code{starpu_sched_ctx_get_min_priority} function. This function should only be
+called from the initialization method of the scheduling policy, and should not
+be used directly from the application.
+@end deftypefun
+
+@deftypefun void starpu_sched_set_max_priority (unsigned @var{sched_ctx_id}, int @var{max_prio})
+Defines the maximum priority level supported by the scheduling policy of the given scheduler context. The
+default maximum priority level is 1.  The application may access that value by
+calling the @code{starpu_sched_ctx_get_max_priority} function. This function should
+only be called from the initialization method of the scheduling policy, and
+should not be used directly from the application.
+@end deftypefun
+
+@deftypefun int starpu_sched_get_min_priority (unsigned @var{sched_ctx_id})
+Returns the current minimum priority level supported by the
+scheduling policy of the given scheduler context.
+@end deftypefun
+
+@deftypefun int starpu_sched_get_max_priority (unsigned @var{sched_ctx_id})
+Returns the current maximum priority level supported by the
+scheduling policy of the given scheduler context.
+@end deftypefun
+
 @node Scheduling Policy
 @section Scheduling Policy
 
@@ -3696,29 +3725,29 @@ It is memorize through a local structure. This function assigns it to a scheduli
 Returns the policy data previously assigned to a context
 @end deftypefun
 
-@deftypefun void starpu_task_set_min_priority (int @var{min_prio})
+@deftypefun void starpu_sched_set_min_priority (int @var{min_prio})
 Defines the minimum task priority level supported by the scheduling policy. The
 default minimum priority level is the same as the default priority level which
 is 0 by convention.  The application may access that value by calling the
-@code{starpu_task_get_min_priority} function. This function should only be
+@code{starpu_sched_get_min_priority} function. This function should only be
 called from the initialization method of the scheduling policy, and should not
 be used directly from the application.
 @end deftypefun
 
-@deftypefun void starpu_task_set_max_priority (int @var{max_prio})
+@deftypefun void starpu_sched_set_max_priority (int @var{max_prio})
 Defines the maximum priority level supported by the scheduling policy. The
 default maximum priority level is 1.  The application may access that value by
-calling the @code{starpu_task_get_max_priority} function. This function should
+calling the @code{starpu_sched_get_max_priority} function. This function should
 only be called from the initialization method of the scheduling policy, and
 should not be used directly from the application.
 @end deftypefun
 
-@deftypefun int starpu_task_get_min_priority (void)
+@deftypefun int starpu_sched_get_min_priority (void)
 Returns the current minimum priority level supported by the
 scheduling policy
 @end deftypefun
 
-@deftypefun int starpu_task_get_max_priority (void)
+@deftypefun int starpu_sched_get_max_priority (void)
 Returns the current maximum priority level supported by the
 scheduling policy
 @end deftypefun

+ 0 - 5
include/starpu_deprecated_api.h

@@ -88,11 +88,6 @@ typedef enum starpu_access_mode starpu_access_mode;
 #define starpu_depth_block_filter_func_block		starpu_block_filter_depth_block
 #define starpu_depth_block_shadow_filter_func_block	starpu_block_filter_depth_block_shadow
 
-#define starpu_sched_get_min_priority		starpu_task_get_min_priority
-#define starpu_sched_get_max_priority		starpu_task_get_max_priority
-#define starpu_sched_set_min_priority		starpu_task_set_min_priority
-#define starpu_sched_set_max_priority		starpu_task_set_max_priority
-
 #endif /* STARPU_USE_DEPRECATED_ONE_ZERO_API */
 
 #ifdef __cplusplus

+ 24 - 0
include/starpu_sched_ctx.h

@@ -24,6 +24,30 @@ extern "C"
 {
 #endif
 
+/*
+ *	Priorities
+ */
+int starpu_sched_get_min_priority(void);
+int starpu_sched_get_max_priority(void);
+
+int starpu_sched_set_min_priority(int min_prio);
+int starpu_sched_set_max_priority(int max_prio);
+
+int starpu_sched_ctx_get_min_priority(unsigned sched_ctx_id);
+int starpu_sched_ctx_get_max_priority(unsigned sched_ctx_id);
+
+int starpu_sched_ctx_set_min_priority(unsigned sched_ctx_id, int min_prio);
+int starpu_sched_ctx_set_max_priority(unsigned sched_ctx_id, int max_prio);
+
+/* Provided for legacy reasons */
+#define STARPU_MIN_PRIO		(starpu_sched_get_min_priority())
+#define STARPU_MAX_PRIO		(starpu_sched_get_max_priority())
+
+/* By convention, the default priority level should be 0 so that we can
+ * statically allocate tasks with a default priority. */
+#define STARPU_DEFAULT_PRIO	0
+
+
 struct starpu_sched_ctx_performance_counters
 {
 	void (*notify_idle_cycle)(unsigned sched_ctx_id, int worker, double idle_time);

+ 0 - 17
include/starpu_task.h

@@ -213,23 +213,6 @@ struct starpu_task
 	unsigned scheduled;
 };
 
-/*
- *	Priorities
- */
-int starpu_task_get_min_priority(void);
-int starpu_task_get_max_priority(void);
-
-void starpu_task_set_min_priority(int min_prio);
-void starpu_task_set_max_priority(int max_prio);
-
-/* Provided for legacy reasons */
-#define STARPU_MIN_PRIO		(starpu_task_get_min_priority())
-#define STARPU_MAX_PRIO		(starpu_task_get_max_priority())
-
-/* By convention, the default priority level should be 0 so that we can
- * statically allocate tasks with a default priority. */
-#define STARPU_DEFAULT_PRIO	0
-
 /* It is possible to initialize statically allocated tasks with this value.
  * This is equivalent to initializing a starpu_task structure with the
  * starpu_task_init function. */

+ 0 - 1
src/Makefile.am

@@ -155,7 +155,6 @@ libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES = 						\
 	core/sched_policy.c					\
 	core/simgrid.c						\
 	core/sched_ctx.c					\
-	core/priorities.c					\
 	core/parallel_task.c					\
 	sched_policies/eager_central_policy.c			\
 	sched_policies/eager_central_priority_policy.c		\

+ 0 - 49
src/core/priorities.c

@@ -1,49 +0,0 @@
-/* StarPU --- Runtime system for heterogeneous multicore architectures.
- *
- * Copyright (C) 2010  Université de Bordeaux 1
- *
- * StarPU is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * StarPU is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
-
-#include <starpu.h>
-#include <starpu_scheduler.h>
-#include <common/config.h>
-
-/* By default we have a binary type of priority: either a task is a priority
- * task (level 1) or it is not (level 0). */
-static int sched_min_prio = 0;
-static int sched_max_prio = 1;
-
-/* The scheduling policy may set its own priority bounds in case it supports
- * different priority levels. These methods should only be called from the
- * scheduling policy. */
-void starpu_task_set_min_priority(int min_prio)
-{
-	sched_min_prio = min_prio;
-}
-
-void starpu_task_set_max_priority(int max_prio)
-{
-	sched_max_prio = max_prio;
-}
-
-/* Returns the minimum priority level supported by the scheduling policy. */
-int starpu_task_get_min_priority(void)
-{
-	return sched_min_prio;
-}
-
-/* Returns the maximum priority level supported by the scheduling policy. */
-int starpu_task_get_max_priority(void)
-{
-	return sched_max_prio;
-}

+ 48 - 0
src/core/sched_ctx.c

@@ -245,6 +245,8 @@ struct _starpu_sched_ctx*  _starpu_create_sched_ctx(const char *policy_name, int
 	sched_ctx->name = sched_name;
 	sched_ctx->inheritor = STARPU_NMAX_SCHED_CTXS;
 	sched_ctx->finished_submit = 0;
+	sched_ctx->min_priority = 0;
+	sched_ctx->max_priority = 1;
 
 	_starpu_barrier_counter_init(&sched_ctx->tasks_barrier, 0);
 
@@ -1054,3 +1056,49 @@ void starpu_sched_ctx_call_pushed_task_cb(int workerid, unsigned sched_ctx_id)
 		sched_ctx->perf_counters->notify_pushed_task(sched_ctx_id, workerid);
 }
 #endif //STARPU_USE_SCHED_CTX_HYPERVISOR
+
+int starpu_sched_get_min_priority(void)
+{
+	return starpu_sched_ctx_get_min_priority(0);
+}
+
+int starpu_sched_get_max_priority(void)
+{
+	return starpu_sched_ctx_get_max_priority(0);
+}
+
+int starpu_sched_set_min_priority(int min_prio)
+{
+	return starpu_sched_ctx_set_min_priority(0, min_prio);
+}
+
+int starpu_sched_set_max_priority(int max_prio)
+{
+	return starpu_sched_ctx_set_max_priority(0, max_prio);
+}
+
+int starpu_sched_ctx_get_min_priority(unsigned sched_ctx_id)
+{
+	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
+	return sched_ctx->min_priority;
+}
+
+int starpu_sched_ctx_get_max_priority(unsigned sched_ctx_id)
+{
+	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
+	return sched_ctx->max_priority;
+}
+
+int starpu_sched_ctx_set_min_priority(unsigned sched_ctx_id, int min_prio)
+{
+	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
+	sched_ctx->min_priority = min_prio;
+	return 0;
+}
+
+int starpu_sched_ctx_set_max_priority(unsigned sched_ctx_id, int max_prio)
+{
+	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
+	sched_ctx->max_priority = max_prio;
+	return 0;
+}

+ 5 - 0
src/core/sched_ctx.h

@@ -89,6 +89,11 @@ struct _starpu_sched_ctx
 	   to this context*/
 	unsigned finished_submit;
 
+        /* By default we have a binary type of priority: either a task is a priority
+         * task (level 1) or it is not (level 0). */
+     	int min_priority;
+	int max_priority;
+
 #ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
 	/* a structure containing a series of performance counters determining the resize procedure */
 	struct starpu_sched_ctx_performance_counters *perf_counters;

+ 2 - 2
src/sched_policies/deque_modeling_policy_data_aware.c

@@ -866,8 +866,8 @@ static void initialize_dmda_sorted_policy(unsigned sched_ctx_id)
 	initialize_dmda_policy(sched_ctx_id);
 
 	/* The application may use any integer */
-	starpu_task_set_min_priority(INT_MIN);
-	starpu_task_set_max_priority(INT_MAX);
+	starpu_sched_ctx_set_min_priority(sched_ctx_id, INT_MIN);
+	starpu_sched_ctx_set_max_priority(sched_ctx_id, INT_MAX);
 }
 
 static void deinitialize_dmda_policy(unsigned sched_ctx_id)

+ 3 - 2
src/sched_policies/eager_central_priority_policy.c

@@ -80,13 +80,14 @@ static void initialize_eager_center_priority_policy(unsigned sched_ctx_id)
 	struct _starpu_eager_central_prio_data *data = (struct _starpu_eager_central_prio_data*)malloc(sizeof(struct _starpu_eager_central_prio_data));
 
 	/* In this policy, we support more than two levels of priority. */
-	starpu_task_set_min_priority(MIN_LEVEL);
-	starpu_task_set_max_priority(MAX_LEVEL);
+	starpu_sched_ctx_set_min_priority(sched_ctx_id, MIN_LEVEL);
+	starpu_sched_ctx_set_max_priority(sched_ctx_id, MAX_LEVEL);
 
 	/* only a single queue (even though there are several internaly) */
 	data->taskq = _starpu_create_priority_taskq();
 	starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)data);
 	_STARPU_PTHREAD_MUTEX_INIT(&data->policy_mutex, NULL);
+
 }
 
 static void deinitialize_eager_center_priority_policy(unsigned sched_ctx_id)