Explorar el Código

The functions starpu_sched_set/get_min/max_priority set/get the
priorities of the current scheduling context, i.e the one which was
set by a call to starpu_sched_ctx_set_context() or the initial context
if the function was not called yet.

Nathalie Furmento hace 12 años
padre
commit
c1bcca575d
Se han modificado 4 ficheros con 25 adiciones y 4 borrados
  1. 4 0
      ChangeLog
  2. 4 0
      doc/doxygen/chapters/api/scheduling_policy.doxy
  3. 13 4
      src/core/sched_ctx.c
  4. 4 0
      src/core/sched_ctx.h

+ 4 - 0
ChangeLog

@@ -89,6 +89,10 @@ Changes:
   * Function starpu_sched_ctx_create() now takes a variable argument
     list to define the scheduler to be used, and the minimum and
     maximum priority values
+  * The functions starpu_sched_set/get_min/max_priority set/get the
+    priorities of the current scheduling context, i.e the one which
+    was set by a call to starpu_sched_ctx_set_context() or the initial
+    context if the function was not called yet.
 
 StarPU 1.1.0 (svn revision xxxx)
 ==============================================

+ 4 - 0
doc/doxygen/chapters/api/scheduling_policy.doxy

@@ -76,6 +76,7 @@ block and wake up all workers.
 
 \fn int starpu_sched_set_min_priority(int min_prio)
 \ingroup API_Scheduling_Policy
+TODO: check if this is correct
 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
@@ -86,6 +87,7 @@ application.
 
 \fn int starpu_sched_set_max_priority(int max_prio)
 \ingroup API_Scheduling_Policy
+TODO: check if this is correct
 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 function starpu_sched_get_max_priority().
@@ -95,11 +97,13 @@ application.
 
 \fn int starpu_sched_get_min_priority(void)
 \ingroup API_Scheduling_Policy
+TODO: check if this is correct
 Returns the current minimum priority level supported by the scheduling
 policy
 
 \fn int starpu_sched_get_max_priority(void)
 \ingroup API_Scheduling_Policy
+TODO: check if this is correct
 Returns the current maximum priority level supported by the scheduling
 policy
 

+ 13 - 4
src/core/sched_ctx.c

@@ -842,6 +842,15 @@ unsigned starpu_sched_ctx_get_context()
 	return *sched_ctx;
 }
 
+unsigned _starpu_sched_ctx_get_current_context()
+{
+	unsigned sched_ctx = starpu_sched_ctx_get_context();
+	if (sched_ctx == STARPU_NMAX_SCHED_CTXS)
+		return _starpu_get_initial_sched_ctx()->id;
+	else
+		return sched_ctx;
+}
+
 void starpu_sched_ctx_notify_hypervisor_exists()
 {
 	with_hypervisor = 1;
@@ -1105,22 +1114,22 @@ void starpu_sched_ctx_call_pushed_task_cb(int workerid, unsigned sched_ctx_id)
 
 int starpu_sched_get_min_priority(void)
 {
-	return starpu_sched_ctx_get_min_priority(_starpu_get_initial_sched_ctx()->id);
+	return starpu_sched_ctx_get_min_priority(_starpu_sched_ctx_get_current_context());
 }
 
 int starpu_sched_get_max_priority(void)
 {
-	return starpu_sched_ctx_get_max_priority(_starpu_get_initial_sched_ctx()->id);
+	return starpu_sched_ctx_get_max_priority(_starpu_sched_ctx_get_current_context());
 }
 
 int starpu_sched_set_min_priority(int min_prio)
 {
-	return starpu_sched_ctx_set_min_priority(_starpu_get_initial_sched_ctx()->id, min_prio);
+	return starpu_sched_ctx_set_min_priority(_starpu_sched_ctx_get_current_context(), min_prio);
 }
 
 int starpu_sched_set_max_priority(int max_prio)
 {
-	return starpu_sched_ctx_set_max_priority(_starpu_get_initial_sched_ctx()->id, max_prio);
+	return starpu_sched_ctx_set_max_priority(_starpu_sched_ctx_get_current_context(), max_prio);
 }
 
 int starpu_sched_ctx_get_min_priority(unsigned sched_ctx_id)

+ 4 - 0
src/core/sched_ctx.h

@@ -179,6 +179,10 @@ void _starpu_sched_ctx_signal_worker_blocked(int workerid);
 /* Notifies the hypervisor that a tasks was poped from the workers' list */
 void _starpu_sched_ctx_post_exec_task_cb(int workerid, struct starpu_task *task, size_t data_size, uint32_t footprint);
 
+/* If starpu_sched_ctx_set_context() has been called, returns the context
+ * id set by its last call, or the id of the initial context */
+unsigned _starpu_sched_ctx_get_current_context();
+
 #endif //STARPU_USE_SC_HYPERVISOR
 
 #endif // __SCHED_CONTEXT_H__