Explorar o código

Add STARPU_SCHED_SORTED_ABOVE and STARPU_SCHED_SORTED_BELOW environment variables

Samuel Thibault %!s(int64=4) %!d(string=hai) anos
pai
achega
faccf2162a

+ 2 - 0
ChangeLog

@@ -82,6 +82,8 @@ Small features:
   * Add STARPU_SIMGRID environment variable guard against native builds.
   * Add starpu_cuda_get_nvmldev function.
   * Add starpu_sched_tree_deinitialize function.
+  * Add STARPU_SCHED_SORTED_ABOVE and STARPU_SCHED_SORTED_BELOW environment
+    variables.
 
 StarPU 1.3.7
 ====================================================================

+ 5 - 2
doc/doxygen/chapters/320_scheduling.doxy

@@ -155,11 +155,14 @@ Heterogeneous Earliest Finish Time.
 It needs that every task submitted to StarPU have a
 defined performance model (\ref PerformanceModelCalibration)
 to work efficiently, but can handle tasks without a performance
-model. <b>modular-heft</b> just takes tasks by priority order. <b>modular-heft2</b> takes
+model. <b>modular-heft</b> just takes tasks by order. <b>modular-heft2</b> takes
 at most 5 tasks of the same priority and checks which one fits best.
 <b>modular-heft-prio</b> is similar to <b>modular-heft</b>, but only decides the memory
 node, not the exact worker, just pushing tasks to one central queue per memory
-node.
+node. By default, they sort tasks by priorities and privilege running first
+a task which has most of its data already available on the target. These can
+however be changed with \ref STARPU_SCHED_SORTED_ABOVE, \ref
+STARPU_SCHED_SORTED_BELOW, and \ref STARPU_SCHED_READY .
 
 - <b>modular-heteroprio</b> is a Heteroprio Scheduler: \n
 Maps tasks to worker similarly to HEFT, but first attribute accelerated tasks to

+ 16 - 0
doc/doxygen/chapters/501_environment_variables.doxy

@@ -583,6 +583,22 @@ pick up a task which has most of its data already available. Setting this to 0
 disables this.
 </dd>
 
+<dt>STARPU_SCHED_SORTED_ABOVE</dt>
+<dd>
+\anchor STARPU_SCHED_SORTED_ABOVE
+\addindex __env__STARPU_SCHED_SORTED_ABOVE
+For a modular scheduler with queues above the decision component, it is
+usually sorted by priority. Setting this to 0 disables this.
+</dd>
+
+<dt>STARPU_SCHED_SORTED_BELOW</dt>
+<dd>
+\anchor STARPU_SCHED_SORTED_BELOW
+\addindex __env__STARPU_SCHED_SORTED_BELOW
+For a modular scheduler with queues below the decision component, they are
+usually sorted by priority. Setting this to 0 disables this.
+</dd>
+
 <dt>STARPU_IDLE_POWER</dt>
 <dd>
 \anchor STARPU_IDLE_POWER

+ 9 - 3
src/sched_policies/modular_ez.c

@@ -93,13 +93,16 @@ void starpu_sched_component_initialize_simple_schedulers(unsigned sched_ctx_id,
 		(void) create_decision_component;
 		(void) data;
 
+		int above_prio = starpu_get_env_number_default("STARPU_SCHED_SORTED_ABOVE", flags & STARPU_SCHED_SIMPLE_FIFO_ABOVE_PRIO ? 1 : 0);
+		int below_prio = starpu_get_env_number_default("STARPU_SCHED_SORTED_BELOW", flags & STARPU_SCHED_SIMPLE_FIFOS_BELOW_PRIO ? 1 : 0);
+
 		/* Create combined workers if requested */
 		if (flags & STARPU_SCHED_SIMPLE_COMBINED_WORKERS)
 			starpu_sched_find_all_worker_combinations();
 
 		/* Components parameters */
 
-		if (flags & STARPU_SCHED_SIMPLE_FIFO_ABOVE_PRIO || flags & STARPU_SCHED_SIMPLE_FIFOS_BELOW_PRIO)
+		if (above_prio || below_prio)
 		{
 			/* The application may use any integer */
 			if (starpu_sched_ctx_min_priority_is_set(sched_ctx_id) == 0)
@@ -188,6 +191,9 @@ void starpu_sched_component_initialize_simple_schedulers(unsigned sched_ctx_id,
 		void *data = va_arg(varg_list, void *);
 		flags = va_arg(varg_list, unsigned);
 
+		int above_prio = starpu_get_env_number_default("STARPU_SCHED_SORTED_ABOVE", flags & STARPU_SCHED_SIMPLE_FIFO_ABOVE_PRIO ? 1 : 0);
+		int below_prio = starpu_get_env_number_default("STARPU_SCHED_SORTED_BELOW", flags & STARPU_SCHED_SIMPLE_FIFOS_BELOW_PRIO ? 1 : 0);
+
 		if (nbelow == 1 && !(flags & STARPU_SCHED_SIMPLE_DECIDE_ALWAYS))
 		{
 			/* Oh, no choice, we don't actually need to decide, just
@@ -206,7 +212,7 @@ void starpu_sched_component_initialize_simple_schedulers(unsigned sched_ctx_id,
 		if (flags & STARPU_SCHED_SIMPLE_FIFO_ABOVE)
 		{
 			struct starpu_sched_component *fifo_above;
-			if (flags & STARPU_SCHED_SIMPLE_FIFO_ABOVE_PRIO)
+			if (above_prio)
 			{
 				fifo_above = starpu_sched_component_prio_create(t, NULL);
 			}
@@ -309,7 +315,7 @@ void starpu_sched_component_initialize_simple_schedulers(unsigned sched_ctx_id,
 					&& i >= starpu_worker_get_count()))
 			{
 				struct starpu_sched_component *fifo_below;
-				if (flags & STARPU_SCHED_SIMPLE_FIFOS_BELOW_PRIO)
+				if (below_prio)
 				{
 					fifo_below = starpu_sched_component_prio_create(t, &prio_data);
 				}